Hi.,
In my page i have a form which has a list box named mediatype which has few values (type1,type2... ).
An ajax function is called in the onchange event and the correcponding publication types are displayed in the ajax page which displays below the mediatype listbox.
similarly three more listboxes are displayed when the publication type is changed, using the same ajax function.
all works fine.,
but when i submit the page and retrieve the posted value no value is returned., i get null values for all the fields or listboxes that are generated through ajax.
any help..
below is my complete code.,
thanks.,
regards
vijay
code for ajx1.php
code for ajx2.php
In my page i have a form which has a list box named mediatype which has few values (type1,type2... ).
An ajax function is called in the onchange event and the correcponding publication types are displayed in the ajax page which displays below the mediatype listbox.
similarly three more listboxes are displayed when the publication type is changed, using the same ajax function.
all works fine.,
but when i submit the page and retrieve the posted value no value is returned., i get null values for all the fields or listboxes that are generated through ajax.
any help..
below is my complete code.,
thanks.,
regards
vijay
Code:
<html> <head> <script type="text/javascript"> function createRequestObj() { var xmlHttp = null; if (window.XMLHttpRequest){ xmlHttp = new XMLHttpRequest(); if (xmlHttp.overrideMimeType) { xmlHttp.overrideMimeType('text/html'); } } else { if (window.ActiveXObject){ xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); if (xmlHttp.overrideMimeType) { xmlHttp.overrideMimeType('text/html'); } } } return xmlHttp; } function ajx1(vari1,vari2) { var d = new Date(); var time = d.getTime(); if(vari1=='media') var url = "ajx1.php?Time="+time; else if(vari1=='pub_type') var url = "ajx2.php?Time="+time; url = url + "&data="+vari2; var xmlHttp =createRequestObj(); xmlHttp.open("GET",url,true); xmlHttp.onreadystatechange = function() { if(xmlHttp.readyState==4) { if(vari1=='media') document.getElementById("media").innerHTML=xmlHttp.responseText; else if(vari1=='pub_type') { document.getElementById("pub_type_tr").style.display='block'; document.getElementById("pub_type").innerHTML=xmlHttp.responseText; } } }; xmlHttp.send(null); } </script> </head> <body> <table width="100%"> <form action="<?php $_SERVER['PHP_SELF'];?>" method="post" name="form1" id="form1"> <tr> <td align="right" valign="top"><strong>Media type</strong></td> <td align="left" valign="top"> </td> <td align="left" valign="top"><select name="mediatype" id="mediatype" onchange="ajx1('media',this.value)"> <option value="select" selected>-----select-----</option> <option value="type1">type1</option> <option value="type2">type2</option> </select> </td> </tr> <tr id="media"> <td align="right" valign="middle"> </td> <td align="left" valign="middle"> </td> <td align="left" valign="middle"> </td> </tr> <tr id="pub_type_tr" style="display:none;"> <td colspan="3" align="left" valign="top"><table width="100%" id="pub_type"> <tr> <td align="left" valign="top"> </td> </tr> </table></td> </tr> <tr> <td align="right" valign="top"><strong>Date</strong></td> <td align="left" valign="top"> </td> <td align="left" valign="top"><input type="text" name="date" id="date" /></td> </tr> <tr> <td align="right" valign="top"> </td> <td align="left" valign="top"> </td> <td align="left" valign="top"> </td> </tr> <tr> <td align="right" valign="top"> </td> <td align="left" valign="top"> </td> <td align="left" valign="top"><input type="submit" name="submit" id="submit" value="Submit" /></td> </tr> </form> </table> </body> </html>
Code:
<td align="right" height="50px" valign="middle"><strong>Publication type</strong></td> <td align="left" valign="middle"> </td> <td align="left" valign="middle"><select name="pubtype" id="pubtype" onChange="ajx1('pub_type',this.value);"> <option selected="selected" value="select">-----select-----</option> <?php include 'config.php'; $meditype=$_GET['data']; $qp=mysql_query("select distinct(publication_type) from media_newspaper order by publication_type asc"); while($rp=mysql_fetch_object($qp)) echo '<option value="'.$rp->publication_type.'">'.$rp->publication_type.'</option>'; ?> </select></td>
Code:
<?php include 'config.php'; $mediatype=$_GET['data']; $qp=mysql_query("select * from media_newspaper where publication_type='".$mediatype."'"); while($rp=mysql_fetch_object($qp)) { $tmpsizes[]=$rp->size; $tmpcolors[]=$rp->color; $tmpposition[]=$rp->position; } ?> <tr> <td width="35%" align="right" valign="top"><strong>Size</strong></td> <td width="6%" align="left" valign="top"> </td> <td width="59%" align="left" valign="top"><select name="size" id="size"> <?php foreach($tmpsizes as $key=>$value) echo '<option value="'.$value.'">'.$value.'</option>'; ?> </select> </td> </tr> <tr> <td align="right" valign="top"> </td> <td align="left" valign="top"> </td> <td align="left" valign="top"> </td> </tr> <tr> <td align="right" valign="top"><strong>Color</strong></td> <td align="left" valign="top"> </td> <td align="left" valign="top"><select name="color" id="color"> <?php foreach($tmpcolors as $key=>$value) echo '<option value="'.$value.'">'.$value.'</option>'; ?> </select> </td> </tr> <tr> <td align="right" valign="top"> </td> <td align="left" valign="top"> </td> <td align="left" valign="top"> </td> </tr> <tr> <td align="right" valign="top"><strong>Position</strong></td> <td align="left" valign="top"> </td> <td align="left" valign="top"><select name="position" id="position"> <?php foreach($tmpposition as $key=>$value) echo '<option value="'.$value.'">'.$value.'</option>'; ?> </select> </td> </tr>
Comment