Announcement

Collapse
No announcement yet.

Ein Block JavaScript Code in der Konsole und über mehere Seiten hinweg ausführen

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ein Block JavaScript Code in der Konsole und über mehere Seiten hinweg ausführen

    Der Code soll das Formular auf Seite A ausfüllen und dann auch die nächste Seite B über einen Klick auf den Submit Button und dem anschiesenden Füllen , füllen.
    Das Problem ist dass es sobald es die Seite wechselt den rest nicht mehr durchführt

    var iKnopf = document.createElement("button");
    var Text = document.createTextNode("Macro ausführen");
    iKnopf.appendChild(Text);
    iKnopf.onclick = function() {
    alert("Hallo");

    document.testformular.Vorname.value = "Tom";
    document.testformular.Zuname.value = "Müller";
    document.testformular.Wohnort.value = "München";
    document.testformular.auswahl[0].checked=true;
    document.testformular.Zahlmethode.value = "Visa";
    document.getElementById("submit").click();


    document.testformular2.auswahl[2].checked=true;
    document.testformular2.Zahlmethode.value = "AmericanExpress";

    }
    document.getElementById("Formular").appendChild(iK nopf);






    Testseite:


    <!DOCTYPE html>
    <html lang="de">
    <head>
    <meta charset="UTF-8">
    <title>Testseite</title>
    </head>

    <body>
    <div id="Formular">
    <form action="testseite2.html" name="testformular">
    <fieldset>
    Vorname: <input type="text" name="Vorname" maxlength="30"><br>
    Nachname: <input type="text" name="Zuname" maxlength="40"><br>
    Wohnort: <input type="text" name="Wohnort" maxlength="40"><br>
    </fieldset>
    <fieldset>
    Option A:<input type="checkbox" name="auswahl" value="Option A"><br>
    Option B:<input type="checkbox" name="auswahl" value="Option B"><br>
    Option C:<input type="checkbox" name="auswahl" value="Option C"><br>
    </fieldset>
    <fieldset>
    Mastercard:<input type="radio" id="mc" name="Zahlmethode" value="Mastercard"><br>
    Visa:<input type="radio" id="vi" name="Zahlmethode" value="Visa"><br>
    AmericanExpress:<input type="radio" id="ae" name="Zahlmethode" value="AmericanExpress"><br>
    </fieldset>
    <button id="submit" type="submit">senden</button>
    </form>
    </div>
    </body>
    </html>





    Testseite2:



    <!DOCTYPE html>
    <html lang="de">
    <head>
    <meta charset="UTF-8">
    <title>Testseite</title>
    </head>

    <body>
    <div id="Formular">
    <form action="testseite1.html" name="testformular2">
    <fieldset>
    Option A:<input type="checkbox" name="auswahl" value="Option A"><br>
    Option B:<input type="checkbox" name="auswahl" value="Option B"><br>
    Option C:<input type="checkbox" name="auswahl" value="Option C"><br>
    </fieldset>
    <fieldset>
    Mastercard:<input type="radio" id="mc" name="Zahlmethode" value="Mastercard"><br>
    Visa:<input type="radio" id="vi" name="Zahlmethode" value="Visa"><br>
    AmericanExpress:<input type="radio" id="ae" name="Zahlmethode" value="AmericanExpress"><br>
    </fieldset>
    <button id="submit" type="submit">senden</button>
    </form>
    </div>
    </body>
    </html>


  • #2
    Bei eine submit wird das Formular an den Server gesandt. Dabei werden die Formularfelder mitgeliefert.
    Deine Action
    form action="testseite2.html" name="testformular"
    muss also keine HTML-Seite audfrufen, sondern ein serverseitiges Script, welches die Formulardaten entgegen nimmt und die 2. Seite ausgibt. Dabei werden per serverseitiger Sprache die Daten in die 2. Seite gesetzt.
    Christian

    Comment

    Working...
    X