By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,825 Members | 1,258 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,825 IT Pros & Developers. It's quick & easy.

form post not detecting input fields added via AJAX

omerbutt
100+
P: 638
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
Expand|Select|Wrap|Line Numbers
  1. var xmlCartInputs;
  2. function getCartInputs(val){
  3.     if(val!="none"){
  4.         xmlCartInputs=GetXmlHttpObject();
  5.         if(xmlCartInputs==null){
  6.             alert("Please Upgrade Your Browser");
  7.             return;
  8.         }else{
  9.             var url="installation/inputs.php";
  10.             var str_tf="t_inputs="+val;
  11.             xmlCartInputs.onreadystatechange=$loadPages;
  12.             xmlCartInputs.open("POST",url,true);
  13.             xmlCartInputs.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
  14.             xmlCartInputs.send(str_tf);
  15.         }
  16.     }
  17. }
  18. function $loadPages(){
  19.     if(xmlCartInputs.readyState==4){
  20.         if(xmlCartInputs.status==200){
  21.             document.getElementById("cart_inputs").innerHTML=xmlCartInputs.responseText;
  22.         }
  23.     }
  24. }
  25.  
Expand|Select|Wrap|Line Numbers
  1. <form name="step2" id="step2" target="_self" method="post" onsubmit="return formchk(this);" action="">
  2.                 <tr>
  3.                     <td></td>
  4.                     <!--<td align="right" valign="middle" width="50"><input type="button" name="prev" id="prev" value="Previous" /></td>-->
  5.                     <td valign="middle" width="50"><input type="submit" name="next_2" id="next_2" value="Next" /></td>
  6.                 </tr>
  7.                 <tr>
  8.                     <td align="center" valign="middle" colspan="3">
  9.                         <table cellspacing="0" cellpadding="5" align="center" width="300" border="0">
  10.                             <tr>
  11.                                 <td valign="middle">Total Cart Columns</td>
  12.                                 <td valign="middle">
  13.                                 <select name="cart_columns" id="cart_columns" onchange="getCartInputs(this.value);">
  14.                                     <option value="none">Select Columns</option>
  15.                                     <?php
  16.                                         for($r=1; $r<=20; $r++){
  17.                                             echo "<option value=\"$r\">$r</option>";
  18.                                         }
  19.                                     ?>
  20.                                 </select>
  21.                                 </td>
  22.                             </tr>
  23.                             <tr>
  24.                                 <td align="center" valign="middle" colspan="2">
  25.                                     <div id="cart_inputs"></div>
  26.                                 </td>
  27.                             </tr>
  28.                         </table>
  29.                     </td>
  30.                 </tr>
  31.             </form>
  32.  
FILE INPUTS.PHP CODE
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
  3.     header('Cache-Control: no-store, no-cache, must-revalidate');
  4.     header('Cache-Control: post-check=0, pre-check=0', FALSE);
  5.     header('Pragma: no-cache'); 
  6.     include("config.php");
  7.     if(isset($_POST['t_inputs'])){
  8.         $tInputs=$_POST['t_inputs'];
  9.         echo '<table cellpadding="5" cellspacing="0" align="center" border="0">';
  10.         for($i=1; $i<=$tInputs; $i++){
  11.             echo '<tr>
  12.                     <td valign="middle">Column Name&nbsp;'.$i.'</td>
  13.                     <td valign="middle"><input type="text" name="column_name_'.$i.'" id="column_name_'.$i.'" value="" /></td>
  14.                 </tr>
  15.                 ';
  16.         }
  17.         echo '</table>';
  18.     }
  19. ?>
  20.  
Dec 17 '09 #1

✓ answered by omerbutt

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

Share this Question
Share on Google+
1 Reply


omerbutt
100+
P: 638
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
Dec 17 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.