grantman
08-20-2007, 10:36 PM
Hi,
I'm trying to take the value selected from a pull-down (<select>) list and have it display in another part of the web page. It works fine in Firefox but not in Internet Explorer (it comes up as the number zero no matter what number you choose). I know there is a known issue in IE with reading values like this, but I cannot figure out how to make this work. Thanks for taking a look.
<script TYPE="text/javascript">
function calculate_answer(form){
//grab value from select box
var theanswer=form.q22.value;
//multiple that by 1.4
theanswer=theanswer*1.4;
//round off to whole number
theanswer=Math.round(theanswer);
//this is the object where answer will be placed
key=document.getElementById("answer_goes_here");
//have that value show up on Q23
key.innerHTML=theanswer;
}
</script>
<form name="myform">
Select the starting number:
<select NAME="q22" ID="q22" ONCHANGE="calculate_answer(document.myform);">
<option VALUE="">--Select--</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
</select>
The calculated number is <span ID="answer_goes_here">(Answer to Q22 goes here)</span>
</form>
I'm trying to take the value selected from a pull-down (<select>) list and have it display in another part of the web page. It works fine in Firefox but not in Internet Explorer (it comes up as the number zero no matter what number you choose). I know there is a known issue in IE with reading values like this, but I cannot figure out how to make this work. Thanks for taking a look.
<script TYPE="text/javascript">
function calculate_answer(form){
//grab value from select box
var theanswer=form.q22.value;
//multiple that by 1.4
theanswer=theanswer*1.4;
//round off to whole number
theanswer=Math.round(theanswer);
//this is the object where answer will be placed
key=document.getElementById("answer_goes_here");
//have that value show up on Q23
key.innerHTML=theanswer;
}
</script>
<form name="myform">
Select the starting number:
<select NAME="q22" ID="q22" ONCHANGE="calculate_answer(document.myform);">
<option VALUE="">--Select--</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
</select>
The calculated number is <span ID="answer_goes_here">(Answer to Q22 goes here)</span>
</form>