PDA

View Full Version : Change URL based on form select items



gwmbox
01-11-2011, 09:51 AM
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;



<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



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

cindylou
01-11-2011, 09:57 AM
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...

molendijk
01-11-2011, 11:07 AM
See this (http://www.dynamicdrive.com/forums/showthread.php?t=51862).
===
Arie Molendijk.

gwmbox
01-12-2011, 01:19 AM
Sorry I had a look at that page and could not work out where it was helping me with my problem.

Thanks

GW

cindylou
01-12-2011, 03:27 AM
maybe this will help you...

http://www.noupe.com/ajax/45-fresh-out-of-the-oven-jquery-plugins.html

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