r00ttap Posted March 6, 2009 Share Posted March 6, 2009 I'm not asking if PHP can replace onchange, I just want to know why this won't submit or if it will even work with sending values to PHP. <form name="sort" method="post" action="<?php $_SERVER['PHP_SELF'] ?>"> <select name="dselect" onchange="document.sort.sort()"> <?php while($row=mysql_fetch_assoc($department)) { echo "<option value='$row[dcode]'>$row[dcode]</option>"; } ?> </select> <noscript><input type="submit" name="sort" value="Sort" /></noscript><br /> <select name="course_name" size="7" style="width: 500px"> <?php if($sort) { while($c = mysql_fetch_object($run_get_course)) { echo "<option>$c->dcode$c->number - $c->title </option>"; } } else { echo "<option>Please select a department to sort the courses</option>"; } ?> </select> </form> I want the first select "dselect" which selects a department to populate the second select list with the courses within that department. I have a feeling that the onchange is not working because I don't see the browser refreshing at all. What can be done here? Is it just a naming issue? Link to comment https://forums.phpfreaks.com/topic/148248-using-onchange-to-populate-select-list-with-php/ Share on other sites More sharing options...
JonnoTheDev Posted March 6, 2009 Share Posted March 6, 2009 You need to look at your JS function. get it to display an alert() when the function runs to test the call. You would also be better using an AJAX approach for this issue rather than reloading your pages. Link to comment https://forums.phpfreaks.com/topic/148248-using-onchange-to-populate-select-list-with-php/#findComment-778288 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.