Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-18-2011, 10:59 AM   PM User | #1
Mydas
New to the CF scene

 
Join Date: Oct 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Mydas is an unknown quantity at this point
calculate

here is my code..what i want to do is..depenting from what the user presses from the 3 choices in the form..i want to have a different variable to calculate..ih the user presses the first option then the variable would be -->1
else if presses second option variable --> 2 else variable-->3

Code:

<script>

function foros()
{
var one= document.getElementById ('smth').value;
  

     {
      missing code  help me ;)
     }


	var result=0.15*variable
        document.write('taxis is: ',result)
</script>


select id="smth" name="Smth"  >
    <option  value="0" selected="selected" > no </option> 
    <option  value="1" >yes</option>
    <option  value="2" >maybe</option>
</select>
Mydas is offline   Reply With Quote
Old 10-18-2011, 04:05 PM   PM User | #2
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,260
Thanks: 10
Thanked 532 Times in 526 Posts
devnull69 will become famous soon enough
You are reading the string(!) value of the selected option into the variable "one" already. All you need to do is to convert it to an integer
Code:
var one = document.getElementById('smth').value;
var variable = Number(one);
var result = 0.15*variable;
devnull69 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:59 AM.


Advertisement
Log in to turn off these ads.