I am having an AJAX issue with my code and any help will be appreciated. I have a page at http://getvalueleads.com/provider_registration.php. If you see in the last paragraph of the page where it says Lead Information, there is a drop down for Select Industry, when you select Web Design from there the options are shown below. This is done via AJAX. However when a user selects (checks a box) for any of the subcategory I am not able to save this information in the database through AJAX. I just am not able to find where the information is there in the code to take it from and how to save the value in database. [FONT="]Any help will be appreciated. Thanks Al [/FONT]
If you need help you will need to post the AJAX code for some people to read and tell you where to make changes.
Are you the programmer of this form? If all form tags have a name and value, they are passed in the form. I notice you are using PHP and you can do is check the whole $_POST array with foreach. The values should be in there somewhere. Check: http://us.php.net/foreach Now if ever it is not there, then, there is a problem with your form itself. I understand it is AJAX, but as long as they update the form input tags aside from changing the displayed content on the screen, it should still be passing values properly.
close the alert() with ; function submitform(){ alert('jay'); document.frmregistration.action="provider_registration.php?pop=yes"; document.frmregistration.method="POST"; document.frmregistration.submit(); return true; } otherwise the submitform() code does not run.
Its doesnt matter good practice to have though .. but the part is that i think you may not understand is AJAX is only the middle man for the PHP.. Ajax doesn't do any functions to the database just tells the browser to do things in a manner it doesnt have to refresh. It would be a great idea to post code can't get any help without it only ideas
*********************FUNCTION To Call AJAX Start Here*************************** <SCRIPT language=javascript> var xmlHttp function catChanged(){ if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("subcat").innerHTML=xmlHttp.responseText; } } function oncat_change(cat_id){ if(cat_id==""){ }else{ xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var url="subcat_table.php?cat_id="+cat_id+"&sid="+Math.random() xmlHttp.onreadystatechange=catChanged xmlHttp.open("GET",url,true) xmlHttp.send(null) } } </SCRIPT> *********************FUNCTION To Call AJAX END Here*************************** *********************HTML AND PHP CODE Where I am Populating the Sub category on select of Industries****************** <TABLE cellSpacing="5" cellPadding="2" width="75%" border="0" bgcolor="#FBDFB7" style="border:1px solid #F4A835;"> <FORM name="frmregistration" method="post" onSubmit="javaScript: return validate_registration();"> <tr> <td class="text" width="35%" align="right" valign="top">Industry:</td> <td valign="top" width="60%"> <Select name="cat_id" class="input" style="width:250px" id="cat_id" onchange="oncat_change(this.value, '')"> <option value="">Select a Industry</option> <?//adding options to select tag i.e Models $strsql="select * from gml_category where 1=1"; $result=mysql_query($strsql); echo mysql_error(); while($objrs=mysql_fetch_array($result)){ $slcat_id=$objrs['cat_id']; $cat_name=$objrs['cat_name']; ?> <option value="<?echo $slcat_id;?>" <? if($slcat_id==$cat_id){echo "Selected";}?>><?echo $cat_name;?></option> <? } ?> </select> </td> </tr> <!--Populating Dynamic Sub Category From the data base using AJAX --> <tr> <td class="text" colspan="2" align="center"> <div id="subcat"> </div> </td> </tr> <TR> <TD class="largetext" valign="top" align="center" colspan="4"> <input type="image" src="images/register_now.gif"/> </TD> </TR> </table> </FORM> *****************************************END ******************************************** *********************************Code In (subcat_table.php) START HERE****************************** <?php include("lib/inc.php"); $cat_id=$_REQUEST['cat_id']; //$cat_id=2; if($cat_id!=""){ $ctr=0; $strsql="select * from gml_subcategory where cat_id=".$cat_id; $result=mysql_query($strsql); echo mysql_error(); $ctr=0; while($objrs = mysql_fetch_array($result)){ $subcat_id=$objrs['subcat_id']; $bid_price=$objrs['bid_price']; $subcat_name=$objrs['subcat_name']; $leadboxname=$ctr; $option.="<tr>"; $option.="<TD class='text' align='left'><input type='checkbox' id='subcat_id'"; $option.=" name='subcat_id[]' class='text' value=<".$subcat_id."> ".$subcat_name; $option.="</TD>"; $option.="<TD class='text' valign='top' align='left'><input type='text' name=txt". $subcat_id."value=".$txt_default."class='input' size='5' maxlength='3'></TD>"; $option.="<TD class='text' valign='top' align='left' width='25%'>$".$bid_price."</TD>"; $option.="</tr>"; $ctr+=1; } } //echo $option; //exit; ?> <table width="70%" valign="top"> <tr colspan="2"><td class="text">List of available Sub Category</td></tr> <tr bgcolor="#f3f3f3"> <td align="left" class="text" width="50%"><b>Sub Category </b></td> <td align="left" class="text" width="25%"><b>Max Lead</b></td> <td align="left" class="text" width="25%"><b>$Price </b></td> </tr> <? echo $option; ?> </table> Now can someone sort this mess for me
This should be in the JavaScript forum, not the PHP one. And what do you mean "sort" through the mess?