开发者

Radio buttons use "image swap" array - how do i change my array to use string values instead?

开发者 https://www.devze.com 2023-02-22 21:41 出处:网络
I have an array: function displayStoneCut(box){ var stonecutPics = new Array(5) stonecutPics[0] = \"images/designform7/design-form-07_type6-2.gif\";

I have an array:

function displayStoneCut(box){

var stonecutPics = new Array(5)
stonecutPics[0] = "images/designform7/design-form-07_type6-2.gif";
stonecutPics[1] = "images/designform7/design-form-07_type6-1.gif";
stonecutPics[2] = "images/designform7/design-form-07_type6-3.gif";
stonecutPics[3] = "images/designform7/design-form-07_type6-4.gif";
stonecutPics[4] = "images/designform7/design-form-07_type6-5.gif";
document.getElementById('stonecutpic').src = stonecutPics[parseInt(box.value)];
}

that works with radio buttons

<input name="stonecut" type="radio" onClick="displayStoneCut(this);" value="0" >
<input name="stonecut" type="radio" onClick="displayStoneCut(this);" value="1" checked >

etc.

to swap images lower do开发者_开发百科wn the page here:

<img src="images/designform7/design-form-07_type5-1.gif" width="139" height="161" name="stonepic" id="stonepic"/><img src="images/designform7/design-form-07_type6-1.gif" width="168" height="161" name="stonecutpic" id="stonecutpic"/>

This is all inside a multipage form (controlled through CSS). The issue is that when the form is sent (using ASP and JMail) the values come through as 0, 1, 2 and I want these to come through as strings/word values.

What is the best solution? Modify the array, add another value somehow to the radio button or combine another array?

any help greatly appreciated


What about this:

<input name="stonecut" type="radio" onClick="displayStoneCut(this);" 
    value="images/designform7/design-form-07_type6-2.gif" >
<input name="stonecut" type="radio" onClick="displayStoneCut(this);" 
    value="images/designform7/design-form-07_type6-1.gif" checked >

...
function displayStoneCut(box){
    document.getElementById('stonecutpic').src = box.value;
}

The your form would get the value of the image. Which is what you want?

0

精彩评论

暂无评论...
验证码 换一张
取 消