Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Grabbing select box value doesn't work in IE

    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.

    Code:
    <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>

  • #2
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    Quote Originally Posted by grantman View Post
    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.
    It's not an issue, it's a matter of complete HTML. Try assigning values to the options.

  • Users who have thanked Arty Effem for this post:

    grantman (08-20-2007)

  • #3
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Wow, how did I miss that? Thanks. I wasted several hours on this thinking that IE had a javascript bug that I had to work around when it was just being strict about the form values.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •