Forum Moderators: coopster

Message Too Old, No Replies

drop down box problem again

drop down box without submit button

         

opiston

12:46 am on Aug 26, 2005 (gmt 0)

10+ Year Member



Hi all,
I have 4 files: select.php, select_proc.php, test.php, test_proc.php

In select.php, I have a drop down box which goes to an url once an option is selected, and the url processes the selected option.

select.php:


<head>
<title>select.php</title>
</head>

<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="sel_dept_proc.php?dept=" + sel_dept ;
}
//-->
</script>
<body>
<form>
<select name="select_stuff" onChange="ChangePage(this);">
<option value = "1">blah1</option>
<option value = "2">blah2</option>
<option value = "3">blah3</option>
<form>

select_proc.php: It gets the value of the "select_stuff" and stores it to a session variable for future usage.


<?php
session_start();
include("../func.php");
$sel_dept = $_GET['dept'];
$_SESSION['department'] = $sel_dept;
?>

After select.php and select_proc.php is done, I click another link to access test.php.
test.php has checkboxes for users to click on.

test.php:


<form method = "post" action="test_proc.php" name = "test">
<input type = "checkbox" name = "cl_text[1]">$myrow[0]</input>
<input type = "checkbox" name =
"cl_text[2]">$myrow[0]</input>
<input type = "checkbox" name = 'cl_text[3]'>$myrow[0]</input>
<input name = "update" type = "submit" value = "Submit" onClick = "form.test.action;">

Let's say I click on checkbox 2 and 3.
After I click submit on test.php, the url is suppose to show
[something.com...]
but it shows [something.com...]
so test_proc.php was never executed

So I think there is something wrong with the javascript (which i don't know how to fix).
Does anyone know how to fix this problem? or is there a way to store the value of sel_dept without using javascript?

Please give me some guidance, I have been trying to figure it out for a while.

Best Regards
Opiston

opiston

7:49 am on Aug 26, 2005 (gmt 0)

10+ Year Member



I forgot to mention that the aboved code works just fine with firefox. Firefox actually display the url correctly - www.something.com/main.php?page=test_proc.php

But it doesn't work on iexplore.

Any help is appreciated
Regards
Opiston

dcrombie

10:15 am on Aug 26, 2005 (gmt 0)



What's the purpose of this:

onClick = "form.test.action;"

and what happens if you delete that handler?

opiston

11:57 am on Aug 26, 2005 (gmt 0)

10+ Year Member



Hi dcrombie,
Thanks for helping

I compare the link before and after onClick = form.test.action"; was deleted, they are exactly the same. It is still handling the url incorrectly for some reason.

Regards
Opiston

dcrombie

12:06 pm on Aug 26, 2005 (gmt 0)



What I'd expect to see as the new Location when you submit the form is:

http://www.example.net/test_proc.php?sel_dept=2&cl_text%5B0%5D=on&cl_text%5B1%5D=&update=Submit

The action (test_proc.php) becomes the new page address, followed by the query_string

opiston

9:41 pm on Aug 27, 2005 (gmt 0)

10+ Year Member



Hi dcrombie,
Thanks for trying to help.
Due to time constraint, I have decided to use submit button to solve this problem.

Best Regards
Opiston