Click to See Complete Forum and Search --> : Problem Handling Select Box values


zippers24
07-15-2008, 09:26 AM
I currently have the following form. This is in HTML, although it has been generated dynamically:

<form name="colsizform">

<span class="ProductSize">
<select id=""sizesdrop"" name="sizesdrop" onChange="getValue()">
<option value ="M">M</option>
<option value ="L">L</option>
<\select> != </select>
<br/><br/>
Colours:
</span>

<span class="ProductColour">
<select id="coloursdrop" name="coloursdrop" onChange="getValue()">

<option value="Black with White face">Black with White face</option>
<option value="Navy with Light Blue face">Navy with Light Blue face</option>
<option value="White with Blue face">White with Blue face</option>
<option value="Classic Olive with Beige face">Classic Olive with Beige face</option>
<\select> != </select>
<br/><br/>
</span>
</form>

I also have the follwing JavaScript within the file.

<script language="javascript" type="text/javascript">
function getValue() {
var selected_value = document.colsizform.sizedrop.value;
document.getElementById("value");
value.innerHTML = currentvalue;
document.write (selected_value);
}

</script>

I want the selected_value variable to contain the currently selected size. However when I change the value in the selection box nothing happens, I know the function is being called when I change the value because it will print a variable defined within the function. Could someone please help me to solve this problem?

Any help would be appreciated.

Kor
07-15-2008, 10:04 AM
I currently have the following form. This is in HTML, although it has been generated dynamically:
How? It is important to know because, if you used innerHTML, it will not work, as innerHTML is not a DOM standard method.

zippers24
07-15-2008, 10:54 AM
It is generated in smarty template using smarty variables.

I managed to get it working like this

<script language="javascript" type="text/javascript">
function getValue() {
var currentsize="";
var curre
currentsize= document.getElementById('sizesdrop').value;
document.write(currentsize);

But how can I get it so it picks up the initial value of the box if you don't change your selection, bearing in mind that the options won't always be the same.

Thanks