form post not detecting input fields added via AJAX

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • omerbutt
    Contributor
    • Nov 2006
    • 638

    form post not detecting input fields added via AJAX

    HI I am WORKING ON A PROJECT IN WHICH I HAVE TO CREATE SOME INPUT FIELDS by selecting the number of inputs from a select menu the problem is that when i post the form the fields inside the div are not posted along with the form where as the div in which i am populating the inputs resides within the form
    here is the code
    [code=javascript]
    var xmlCartInputs;
    function getCartInputs(v al){
    if(val!="none") {
    xmlCartInputs=G etXmlHttpObject ();
    if(xmlCartInput s==null){
    alert("Please Upgrade Your Browser");
    return;
    }else{
    var url="installati on/inputs.php";
    var str_tf="t_input s="+val;
    xmlCartInputs.o nreadystatechan ge=$loadPages;
    xmlCartInputs.o pen("POST",url, true);
    xmlCartInputs.s etRequestHeader ("Content-Type","applicat ion/x-www-form-urlencoded; charset=UTF-8");
    xmlCartInputs.s end(str_tf);
    }
    }
    }
    function $loadPages(){
    if(xmlCartInput s.readyState==4 ){
    if(xmlCartInput s.status==200){
    document.getEle mentById("cart_ inputs").innerH TML=xmlCartInpu ts.responseText ;
    }
    }
    }
    [/code]
    [code=html]
    <form name="step2" id="step2" target="_self" method="post" onsubmit="retur n formchk(this);" action="">
    <tr>
    <td></td>
    <!--<td align="right" valign="middle" width="50"><inp ut type="button" name="prev" id="prev" value="Previous " /></td>-->
    <td valign="middle" width="50"><inp ut type="submit" name="next_2" id="next_2" value="Next" /></td>
    </tr>
    <tr>
    <td align="center" valign="middle" colspan="3">
    <table cellspacing="0" cellpadding="5" align="center" width="300" border="0">
    <tr>
    <td valign="middle" >Total Cart Columns</td>
    <td valign="middle" >
    <select name="cart_colu mns" id="cart_column s" onchange="getCa rtInputs(this.v alue);">
    <option value="none">Se lect Columns</option>
    <?php
    for($r=1; $r<=20; $r++){
    echo "<option value=\"$r\">$r </option>";
    }
    ?>
    </select>
    </td>
    </tr>
    <tr>
    <td align="center" valign="middle" colspan="2">
    <div id="cart_inputs "></div>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </form>
    [/code]
    FILE INPUTS.PHP CODE
    [CODE=PHP]
    <?php
    header('Expires : Mon, 26 Jul 1997 05:00:00 GMT');
    header('Cache-Control: no-store, no-cache, must-revalidate');
    header('Cache-Control: post-check=0, pre-check=0', FALSE);
    header('Pragma: no-cache');
    include("config .php");
    if(isset($_POST['t_inputs'])){
    $tInputs=$_POST['t_inputs'];
    echo '<table cellpadding="5" cellspacing="0" align="center" border="0">';
    for($i=1; $i<=$tInputs; $i++){
    echo '<tr>
    <td valign="middle" >Column Name&nbsp;'.$i. '</td>
    <td valign="middle" ><input type="text" name="column_na me_'.$i.'" id="column_name _'.$i.'" value="" /></td>
    </tr>
    ';
    }
    echo '</table>';
    }
    ?>
    [/CODE]
  • omerbutt
    Contributor
    • Nov 2006
    • 638

    #2
    i got it it was just because the HTML was not up to the standards and the form was populated inside the table instead of the td due to which it abnormally closed the form before the inputs div its working now

    Comment

    Working...