|
-
May 4th, 2004, 11:04 AM
#1
Thread Starter
Frenzied Member
Refreshing page after combobox select [Resolved]
I have a combobox and when the user changes the value of this box, I need to refresh the page with that value being sent as a parameter. I know how to handle the parameter with the refresh, but I need to know how to do a refresh from "mypage.php" to "mypage.php?param=x".
Help?
Last edited by ober0330; May 4th, 2004 at 11:30 AM.
-
May 4th, 2004, 11:17 AM
#2
Frenzied Member
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
function refresh_page(_val) {
//we need to get rid of the previous param:
URL = location.href
/*Make sure that this is the last parameter being sent:
eg:
www.a.com/b.php?a=1,b=2,param=3
is ok, but
www.a.com/b.php?a=1,param=3,b=2
is not. This is because this script will get rid of it.
*/
if (URL.search('param') != -1)
{
URL = URL.substring(0,URL.search('param')-1)
}
if (_val != 0)
{
location.href = URL+"?param="+_val
}
}
</script>
</head>
<body>
<select onChange="refresh_page(this.value)">
<option selected value="0">Please select one</option>
<option value="1">category 1</option>
<option value="2">category 2</option>
<option value="3">category 3</option>
<option value="4">category 4</option>
</select>
</body>
</html>
OK, now it works better.
Last edited by Acidic; May 4th, 2004 at 11:29 AM.
Have I helped you? Please Rate my posts. 
-
May 4th, 2004, 11:29 AM
#3
Thread Starter
Frenzied Member
Code:
<select name="CellNum" size="1" onChange="go(this.value)">
Code:
<script language="JavaScript" type="text/javascript">
<!--
function go(_val)
{
URL = location.href
location.href = URL+"?CellNum="+_val
}
-->
</script>
Works great, thanks!
-
May 4th, 2004, 11:31 AM
#4
Frenzied Member
I know that works, but if you submit that time and time again you'll get:
www.a.com/a.html?a=1
then:
www.a.com/a.html?a=1?a=1
then:
www.a.com/a.html?a=1?a=1?a=1
etc.
This script doesn't.
Have I helped you? Please Rate my posts. 
-
May 5th, 2004, 07:48 AM
#5
Thread Starter
Frenzied Member
Good point. Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|