Results 1 to 5 of 5

Thread: Refreshing page after combobox select [Resolved]

  1. #1

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945

    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.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  2. #2
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    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.

  3. #3

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    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!
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  4. #4
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    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.

  5. #5

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    Good point. Thanks.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width