PDA

View Full Version : Option value made up of variables?


bluetech
08-16-2002, 01:15 AM
Hi!
I have a form with a drop down box that has 2 options. The value of each option is a hyperlink. What I need to do is add 2 radio buttons, with the value added to the drop down option. Ex: /addtocart.mart?m=OffshorePursuits&upc=6732ERBL&qty=1

Where "6732" would be the value of the drop down, and "ERBL" would be the value of the radio button checked. Any help woul be greatly appreciated. Thanks!

adios
08-16-2002, 01:37 AM
Close?

<html>
<head>
<title>untitled</title>
</head>
<body>
<form onsubmit="upc[upc.selectedIndex].value+=upc.addon">
<select name="upc">
<option value="6732">option 1 (6732)</option>
<option value="8999">option 2 (8999)</option>
</select>
ERBL<input type="radio" name="code" value="ERBL" onclick="upc.addon=this.value">
LBRE<input type="radio" name="code" value="LBRE" onclick="upc.addon=this.value">
<br><br>
<input type="submit" value="SEND">
</form>
</body>
</html>

bluetech
08-16-2002, 01:42 AM
adios,
I will try that. Thanks again.

bluetech
08-16-2002, 02:23 AM
adios,
I get an error when I try and run the script.
I need the link to read

http://cart.wellsfargoestore.com/addtocart.mart?m=OffshorePursuits&amp;upc=6732ERGR&amp;qty=1

where "6732" is the value of the drop down and "ERGR" is the value of the radio button. Thanks again for the help.

adios
08-16-2002, 02:33 AM
Post what you're working with....

bluetech
08-16-2002, 02:46 AM
adios,

<html>
<head>
<title>untitled</title>
</head>
<body>
<form onsubmit="http://cart.wellsfargoestore.com/addtocart.mart?m=OffshorePursuits&amp;upc=[upc.selectedIndex].value+=upc.addon+amp; qty=1">
<select name="upc">
<option value="6732">option 1 (Black)</option>
<option value="8999">option 2 (test)</option>
</select>
ERGR<input type="radio" name="code" value="ERGR" onclick="upc.addon=this.value">
ERGL<input type="radio" name="code" value="ERGL" onclick="upc.addon=this.value">
<br><br>
<input type="submit" value="SEND">
</form>
</body>
</html>

adios
08-16-2002, 03:07 AM
bluetech...

Not following this..are you submitting the form? Simply loading a new page? Normally, a query string is added to the action url when the form is submitted, its name/value pairs coming from the form's elements. I can't see where this is headed, so it's unclear how to do it. Any details would help.

bluetech
08-16-2002, 03:15 AM
adios,

Below is what I have now.

<form name="Eel1"><font color="#1C1C75">Choose
Eel Color:</font> <select name="E1" size="1" style="color: #1C1C75">
<option value="http://cart.wellsfargoestore.com/addtocart.mart?m=OffshorePursuits&amp;upc=6732ERGR&amp;qty=1">Natural</option>

<option value="http://cart.wellsfargoestore.com/addtocart.mart?m=OffshorePursuits&amp;upc=6732ERBL&amp;qty=1">Black</option>
</select><script language="javascript">
<!--
function go53()
{
location=document.Eel1.E1.
options[document.Eel1.E1.selectedIndex].value
}
//-->
</script>

<input type="button" name="test" value="Add To Cart" onClick="go53()">
</form>

When an item is picked in the drop down, the user is taken to a check out page with the appropriate item displayed (6732 ERBL).

The problem is that I need to add new items that have 2 styles, 12 colors, and 4 hook styles.

Everything in the link is constant except "6732ERBL". That will change depending on the items picked. EX: 6732ERBL might mean "Hammered finish, blue, regular hook".

I need that part of the link dictaded by the choices in the drop down and radio buttons.

adios
08-16-2002, 04:29 AM
I have a headache. Tell me this is close:

<html>
<head>
<title>untitled</title>
<script type="text/javascript" language="javascript">

function goToStore(f) {
var url = 'http://cart.wellsfargoestore.com/addtocart.mart?m=OffshorePursuits&upc=';
url += f.upc[f.upc.selectedIndex].value;
for (var i=0; i<f.code.length; ++i) if (f.code[i].checked) url += f.code[i].value;
url += '&qty=1';
alert(url); //demo - remove
//location = url; //uncomment this
}

</script>
</head>
<body>
<form>
<select name="upc">
<option value="6732">black</option>
<option value="6775">natural</option>
</select>
ERBL<input type="radio" name="code" value="ERBL">
ERGR<input type="radio" name="code" value="ERGR">
<br><br>
<input type="button" value="BUY IT" onclick="goToStore(this.form)">
</form>
</body>
</html>

Your last description should have been the first....