单选按钮使用“图像交换”数组 - 如何更改我的数组以使用字符串值?

时间:2011-04-07 07:15:38

标签: javascript arrays string forms radio-button

我有一个数组:

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)];
}

适用于单选按钮

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

在此处向下交换图片:

<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"/>

这都是多页形式(通过CSS控制)。 问题在于,当表单被发送时(使用ASP和JMail),值将变为0,1,2,并且我希望这些值作为字符串/单词值出现。

什么是最佳解决方案?修改数组,以某种方式将另一个值添加到单选按钮或组合另一个数组?

任何帮助非常感谢

1 个答案:

答案 0 :(得分:0)

这个怎么样:

<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;
}

您的表单将获得图像的值。你想要的是什么?