...

View Full Version : Replaced radio buttons with custom script



joshua7
04-23-2008, 08:35 AM
I have replaced normal radio buttons with this script:


<!--

//script to change background-color of the selected
//button and put the appropriate value in an input object
function btnClick(btnNum){
for (i=1;i<=4;i++){
tempBtnVal=document.getElementById('btnVal')
tempBtn=document.getElementById('btn'+i)
tempBtn.style.backgroundColor=(i==btnNum?'#ff0000':'#ffffff')
}
tempBtnVal.value=btnNum
}
//-->

Using this html:


<div id="btn1" name="btn1" class="buttonDiv" onclick="btnClick('1')">Option 1</div>
<div id="btn2" name="btn2" class="buttonDiv" value='2' onclick="btnClick('2')">Option 2</div>
<div id="btn3" name="btn3" class="buttonDiv" value='3' onclick="btnClick('3')">Option 3</div>
<div id="btn4" name="btn4" class="buttonDiv" value='4' onclick="btnClick('4')">Option 4</div>
<input id="btnVal" name="btnVal" type="text" value="" />


The code is not mine. I used to set the variable's value like this:


<input type="radio" name="answer" value="$option1" <if condition="$option1 == $answer">checked="checked"</if> /> $option1
<input type="radio" name="answer" value="$option2" <if condition="$option2 == $answer">checked="checked"</if> /> $option2...

How can I set the variable's value now using the new script?

abduraooft
04-23-2008, 08:43 AM
value="$option1" , $answer is it PHP ?

joshua7
04-23-2008, 02:22 PM
is it PHP ?

yes, it's PHP



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum