Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question select drop down ADDING a parameter to the GET url

    I have a language drop down menu at the top of every page. The idea is you click the drop down, select your new language and the page reloads in that language. Works perfect. The only problem is if the page has OTHER parameters in its existing url. For example, if I'm at www.example.com/person?name=Scott and I try to change the language to en_US, I want the page www.example.com/person?name=Scott&language=en_US to be loaded. However, what actually happens is www.example.com/person?language=en_US is loaded . Here's my code:
    Code:
    <form action="/person?name=Scott" method="get">
      <select name="language" onchange="this.form.submit();">
        <option value="en_US" selected="selected">English (United States)</option>
        <option value="ro_RO">Romanian (Romania)</option>
      </select>
    </form>
    So my question is, is there an easy way to do what I want? Or do I have to insert <input type="hidden"> elements for each existing parameter in the url on each page?

  • #2
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,517
    Thanks
    114
    Thanked 110 Times in 109 Posts
    Thats annoying. Is there a reason you don't want to put the hidden elements in. Are you using php because if so you could write a script to generate the hidden elements something like

    PHP Code:
    <?PHP
    foreach($_GET as $key => $value)
        echo 
    '<input type="hidden" name="'.$key.'" value="'.$value.'">';
    ?>
    You can not say you know how to do something, until you can teach it to someone else.

  • #3
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks timgolding, I was just hoping there was a simple flag I needed to set to enable what I wanted. I'm using Java/Spring, I'll just create those hidden elements.


  •  

    Tags for this Thread

    Posting Permissions

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