tdors Posted May 30, 2007 Share Posted May 30, 2007 Can't figure it out. I have the full code below, but I'm trying to pull data out of mysql based on the value selected from a drop down box, I have the <select size='1' name='".$selectname."' class='".$dropstyle."' onchange='javascript: MyAjaxRequest(\"ajmn\",\"/handle_xsmysqllook.php?state=changed\")'> which is fine, and I know how get variables work, but when I want to add to the end - &sellid=<Drop Down Variable> Thanks in advance for any help! 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; } Link to comment https://forums.phpfreaks.com/topic/53648-javascript-dropdown-to-pass-variable-and-call-ajax/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.