tdors Posted May 29, 2007 Share Posted May 29, 2007 Below is the code that I have. I'm not totally familiar with JavaScript, but I'm getting the AJAX portion to work correctly, but how do I send the value of the drop down item selected to the "AJAX Query"? After "state=changed" I want to add "&xsellid=<The Value ID of the Drop Down>" What is the javascript function for that? Here is the line specifying the Select Statement --> I have the "$toecho .= "\n<select size='1' name='".$selectname."' class='".$dropstyle."' onchange='javascript: MyAjaxRequest(\"ajmn\",\"/handle_xsmysqllook.php?state=changed\")'>\n";" Please let me know if you need to know anything else/I've left anything out. function xselldropchange($selectname, $valueselected, $dropstyle) # $selectname - Name of the drop down box/"<Select>" to use # $valueselected - If specified, which id of the value to display # $dropstyle - Style of Dropdown box # # $toecho - HTML Code to Echo Back # $detailquery - Query to get information # # { $toecho = NULL; # Determine what the mysql query should be $dropquery = "SELECT incentive_id, incentive_name FROM incentive_list ORDER BY incentive_sort"; if ($dropquery <> NULL) { $dropresult = @mysql_query ($dropquery); // Run the query if ($dropresult) { // If this query ran okay $toecho .= "\n<select size='1' name='".$selectname."' class='".$dropstyle."' onchange='javascript: MyAjaxRequest(\"ajmn\",\"/handle_xsmysqllook.php?state=changed\")'>\n"; while ($detailrow = mysql_fetch_array($dropresult, MYSQL_NUM)) { $toecho .= "<option "; if ($detailrow[0] == $valueselected) {$toecho .= "selected ";} $toecho .= "value='".$detailrow[0]."'>".$detailrow[1]."</option>\n"; } $toecho .= "</select>\n"; mysql_free_result ($dropresult); // Free up the result (Good Practice) } else { // If Query was Null $toecho == "<select size='1' name='problem'><option value='0'>No Result $table query $dropquery</option></select>"; } } else { // If Query was Null $toecho == "<select size='1' name='problem'><option value='0'>ERROR IN $table</option></select>"; } return $toecho; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.