Results 1 to 5 of 5

Thread: Change URL based on form select items

  1. #1
    Join Date
    Mar 2005
    Location
    Western Australia
    Posts
    148
    Thanks
    24
    Thanked 4 Times in 4 Posts

    Default Change URL based on form select items

    I am trying to get a URL to be made up from the choice of select items using chained selects so the options are not shown here as they are generated from the chained select script. there are also some hidden fields as shown. What I have so far is;

    HTML Code:
    <form name="item">
      <input type="hidden" name="itemtitle" id="itemtitle" value="mytitle">
      <input type="hidden" name="itemid" name="itemid" value="123456789">
      <fieldset>
        <h4>Style:</h4>
        <select name="style" id="itemstyle" onchange="mylink();"></select>
        <h4>Colour:</h4>
        <select name="color" id="itemcolor" onchange="mylink();"></select>
        <h4>Size:</h4>
        <select name="size" id="itemsize" onchange="mylink();"></select>
      </fieldset>
      <fieldset>
        <h3>Price <span id="itemprice">$50.00 each</span></h3>
        <label for="itemqty">Quantity</label>
        <input type="text" maxlength="5" value="1" id="itemqty" name="itemqty" onchange="itemprice();" size="6">
      </fieldset>
    </form>
    <p class="right"><a href="http://www.mysite.com/productname-123456789?style=basic&color=white&size=350ml" id="itemlink"><img src="/themes/mysite/images/additem.png"></a></p>
    And then the javascript of

    Code:
    function mylink(){
     var itemlink = 'http://www.mysite.com/productname-123456789?style=basic&color=white&size=350ml';
     var myurl = 'mmm.mysite.com';
     var mystyle = document.getElementById('itemstyle').value;
     var mycolor = document.getElementById('itemcolor').value;
     var mysize = document.getElementById('itemsize').value;
     var myTitle = document.getElementById('itemtitle').value;
     var myId = document.getElementById('itemid').value;
     document.getElementById('itemlink').href='http://'+myurl+'/'+myTitle+'_'+myId+'&style='+mystyle+'&color='+mycolor+'&size='+mysize;
    is my code above wrong, if so where and what is the correct code please.

    Thanks

    GW
    1st rule of web development - use Firefox and Firebug
    2nd rule - see the first rule
    --
    I like Smilies

  2. #2
    Join Date
    Jan 2011
    Posts
    50
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    have you tried running this and the rest of the codes?..i would pretty much like to see the output, if you don't mind...i'm still learning html...

  3. #3
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

  4. #4
    Join Date
    Mar 2005
    Location
    Western Australia
    Posts
    148
    Thanks
    24
    Thanked 4 Times in 4 Posts

    Default

    Sorry I had a look at that page and could not work out where it was helping me with my problem.

    Thanks

    GW
    1st rule of web development - use Firefox and Firebug
    2nd rule - see the first rule
    --
    I like Smilies

  5. #5
    Join Date
    Jan 2011
    Posts
    50
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    maybe this will help you...

    http://www.noupe.com/ajax/45-fresh-o...y-plugins.html

    you need to click on the names though to view the code..

Bookmarks

Posting Permissions

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