0

JS CODE:

    function yetiskintext() {

    document.getElementById("yetiskindiv").innerHTML="";
    var secenek=document.getElementById("yetiskinid").value;

    while (secenek>0){
    var newlabel = document.createElement("Label");
    newlabel.setAttribute("for","keke");
    newlabel.innerHTML = "Adı :";
    newlabel.className='selectTravelInputFieldsCarText';
    document.getElementById("yetiskindiv").appendChild(newlabel);   

    var textBoxname = document.createElement('input');
    textBoxname.name = 'textyetiskinname'+secenek;
    textBoxname.id='textyetiskinname'+secenek;
    textBoxname.type = 'text';
    textBoxname.className='selectTravelInputFieldsCar';
    document.getElementById("yetiskindiv").appendChild(textBoxname);

    var newlabel = document.createElement("Label");
    newlabel.setAttribute("for","keke");
    newlabel.innerHTML = "</br>";
    document.getElementById("yetiskindiv").appendChild(newlabel);

MAIN PHP PAGE:

<div id="yetiskindiv"></div>

FORM START:

<form method="post" name="sigortayap"  action="sigorta-process.php" onsubmit="return dene()" >

SIGORTA_PROCESS.PHP:

<?php

    $yetiskinsayisi=htmlspecialchars($_POST["yetiskin"]);

    $cocuksayisi=htmlspecialchars($_POST["cocuk"]);
    $e=1;
     $a=htmlspecialchars($_POST["textyetiskinname".$e]);
    print $a; 

    echo $yetiskinsayisi;
    echo $cocuksayisi;


?>

I want to post my form. My form keeping js page i get form in <div>. How can I post this form ?

1 Answer 1

1

You should have a submit button in your form to submit it:

<input type="submit" value="Submit Form"/>

Here's what i've understood after looking at your code:

<form method="post" name="sigortayap"  action="sigorta-process.php" onsubmit="return dene()" >

when you say, onsubmit="return dene()" and dene() returns false then the form wont submit, so make sure that the function doesn't false.

If you want to do it via code:

<form id="yourform" method="post" name="sigortayap"  action="sigorta-process.php" onsubmit="return dene()" >

and in JS:

yourform.submit()
Sign up to request clarification or add additional context in comments.

1 Comment

Or give that form an id (id="myform") and do in your script: > myform.submit(); then you can trigger it using JavaScript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.