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 4 of 4
  1. #1
    New Coder
    Join Date
    Mar 2004
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts

    concatenation problems...

    PHP Code:
    <select name="select" onChange="'location.href=CatID=3&SectionID=advanced-search&SearchID=' + document.form1.select.options[document.form1.select.selectedIndex].value + '.php'"
    I don't know much about javascript but would like to learn as much as possible. I think there's a concatenation problem in the onChange... Can anyone help me out?

    -Thanks

  • #2
    New Coder
    Join Date
    Jun 2002
    Location
    London & Oxford
    Posts
    97
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think this is what you are trying to do:

    Code:
    <script>
    <!--
    function changePage(picked){
    newPage = 'http://www.whatever.com/'+picked+'.php';
    eval(location.href=newPage);
    }
    -->
    </script>
    
    
    <select name="choose" onchange="changePage(this.options[this.selectedIndex].value)">
    <option value="page1">1</option>
    <option value="page2">2</option>
    </select>
    As easy as 3.1415926535897932384626433832795028841

  • #3
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <script>
    <!--
    function changePage(picked){
    newPage = 'http://www.whatever.com/'+picked+'.php';
    location.href=newPage;
    //eval(location.href=newPage);
    }
    -->
    </script>
    you don't need the eval - that's just superfluous!

  • #4
    New Coder
    Join Date
    Mar 2004
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by head8k
    I think this is what you are trying to do:

    Code:
    <script>
    <!--
    function changePage(picked){
    newPage = 'http://www.whatever.com/'+picked+'.php';
    eval(location.href=newPage);
    }
    -->
    </script>
    
    
    <select name="choose" onchange="changePage(this.options[this.selectedIndex].value)">
    <option value="page1">1</option>
    <option value="page2">2</option>
    </select>
    Thanks Head8k and jbot :-)


  •  

    Posting Permissions

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