Forum Moderators: open
Thanks for your help
I have 2 files involved in my drop down box.
The first file is named: top.php
//I have some query before this startsprint "<form method = 'post' name = 'dept_drop' action = 'top_proc.php'>";
print "<select name='sel_dept' onChange = 'form.dept_drop.action.submit();'>";
while ($myrow = mysql_fetch_array($query)) {
print "<option value=$myrow[1]>$myrow[0]</option>";
}
The second file is named: top_proc.php
When one of the options in the drop down box is selected, I want to go to top_proc.php to process the selected option.
But I don't konw how to redirect to top_proc.php after an option is selected.
I know how to redirect when a submit button is presented, but in this case, I don't want a submit button.
Do you have any suggestions?
Regards
Opiston
I included this javascript into my file.
<script language="JavaScript" type="text/javascript">
<!--
function ChangePage(Opt_List)
{
var sel_dept = Opt_List.options[Opt_List.selectedIndex].value;
sel_dept = sel_dept * 1;
window.location="../top_proc.php?dept=" + sel_dept ;
}
//-->
</script>
Then the form looks like:
<?php
print "<form>";
print "<select name='sel_dept' onChange='ChangePage(this);'>";
while ($myrow = mysql_fetch_row($result)) {
print "<option value=$myrow[1]>$myrow[1]</option>";
}
print "</form>";
?>
top_proc.php receives the value of sel_dept as a parm.
<?php
// top_proc.php
$dept = $_GET['dept'];
echo $dept;
?>
You could then use Mod Rewrite to remove the parameter string from the URL before its displayed to the user.
Thank you for your help once again
Regards
Opiston
Hi The Grizzler,
I heard about dreamweaver before, but I never really used it.
Thanks for your recommendation.
Regards
Opiston
When the user click on the submit button on other page, another page, let's say test_proc.php, comes up to process the input just entered.
So the url should be www.something.com/main.php?page=test_proc.php
But instead it gives me
www.something.com/main.php?sel_dept=2&cl_text%5B0%5D=on=&update=Submit
So that test_proc.php does not get executed.
The strange thing is that it works fine with firefox, but iexplore encounters problem.
Any suggestions?