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 ?
asked Jan 4, 2014 at 0:44
Gökhan Çokkeçeci
1,3983 gold badges16 silver badges37 bronze badges
1 Answer 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
K. Biermann
Or give that form an id (id="myform") and do in your script: > myform.submit(); then you can trigger it using JavaScript.
default