Hi there,
I am very very new to this and would really appreciate a little help!
I am trying to create an HTML version of a FLASH site (
www.rfkharris.com) as I have had feedback that people find it hard to view.
I am trying to generate an price depending on a user's selection from three different drop down menu's. e.g if 'brown' is selected from the first menu, 'red' from the second and 'green' from the third a certain cost will be generated which would be different if the combinations selected were different. The selection chosen should generate a URL as well as the price so that, should the user be happy with the price, they can progress to pay - oh dear, this all sounds awfully complicated!
When looking through the threads on this forum to see if I could find the answer there I found the following code which did exactly what I wanted if I had only one column and did not need to generate a URL as well, I have posted this here for reference.
Many thanks in advance, all help appreciated
<html> <head>
<script language="javascript">
var arrProducts = new Array();
arrProducts[0] = "Widget 1";
arrProducts[1] = "$24.95";
arrProducts[2] = "Widget 2";
arrProducts[3] = "$16.95";
arrProducts[4] = "Green Widget";
arrProducts[5] = "$4.95";
arrProducts[6] = "Blue Widget";
arrProducts[7] = "$7.95";
arrProducts[8] = "Turbo Widget";
arrProducts[9] = "$34.95";
function getPrice(widgetName, priceField)
{
//Iterate through the array
for(i=0;i<arrProducts.length;i++)
{
//Found the product
if(arrProducts[i] == widgetName)
{
//Increment i because the price is
//always the next array element
i++;
//Get the price
var price = arrProducts[i];
//Exit the loop
break;
}
i++;
}
//Update the form element

priceField.value = price;
}
</script>
</head>
<body>
<form name="theForm">
<select name="widgets"
onChange="getPrice(this.options[this.selectedIndex].value, theForm.price);">
<option value="Widget 1">Widget 1</option>
<option value="Widget 2">Widget 2</option>
<option value="Green Widget">Green Widget</option>
<option value="Blue Widget">Blue Widget</option>
<option value="Turbo Widget">Turbo Widget</option>
</select>
<input type="text" name="price" />
</form>
</body>
</html>