![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Web Design & Programming Discussion of web design, and server-side & client-side scripting |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Jan 2007
Posts: 108
OS: window XP
|
javascript question
i completely new to javascript. I have a problem here. I want to get user input number and then sum them and print the total. But the problem is i will get a problem.
Example: 1 + 2 should = 3 but i get 12? how to plus the number? Code:
<script language="javascript">
var num1 = prompt("Enter Number here", "Type here");
var num2 = prompt("Enter Number here", "Type here");
var total;
total = num1+num2;
document.write(total);
</script>
|
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) | |
|
Registered User
Join Date: Jan 2008
Location: Harpers Ferry, WV
Posts: 400
OS: OS X 10.4.x
|
Re: javascript question
JavaScript Prompt
Quote:
|
|
|
|
|
|
|
#5 (permalink) |
|
Registered User
Join Date: Apr 2008
Posts: 2
OS: xp
|
Re: javascript question
I have a similar problem, seen this message and figured it might be a fit to ask for help.
I want to select a checkbox and add the values together, I have it working however if the values are more than 1 for a field it will not work? See below: <script language="JavaScript"> <!-- function calculate(what) { what.answer.value =0; for (var i=1,answer=0;i<6;i++) answer += (what.elements['CourseOrder' + i].checked)&(what.elements['CourseOrder' + i].value-0); what.answer.value = answer; } //--> </script> <form> <INPUT type="checkbox" NAME="CourseOrder1" VALUE="1" onclick="calculate(this.form)"><br> <INPUT type="checkbox" NAME="CourseOrder2" VALUE="1" onclick="calculate(this.form)"><br> <INPUT type="checkbox" NAME="CourseOrder3" VALUE="1" onclick="calculate(this.form)"><br> <INPUT type="checkbox" NAME="CourseOrder4" VALUE="1" onclick="calculate(this.form)"><br> <INPUT type="checkbox" NAME="CourseOrder5" VALUE="1" onclick="calculate(this.form)"><br> <input type="text" name="answer"> </form> Suggestions very welcome, Thanks, Kevin |
|
|
|
|
|
#6 (permalink) |
|
Registered User
Join Date: Jan 2008
Location: Harpers Ferry, WV
Posts: 400
OS: OS X 10.4.x
|
Re: javascript question
Not sure what you mean "if the values are more than 1 for a field". Are you getting an error? If so, what is it as it seems to work fine from what I can see.
Oh and welcome to the Tech Support Forum. |
|
|
|
|
|
#8 (permalink) |
|
Registered User
Join Date: May 2007
Location: British Columbia, Canada
Posts: 53
OS: vista
|
Re: javascript question
Hello folks!
When I execute the following, the i variable value goes straight to 176...but if I take out the 'for' loop statement (and the i variable) it works ok? function testFunction() { for(i=0; i<=176; i++) { setTimeout("Nothing()", 100); doScroll(i+400,0,176-i,140,0); } } Thanks. |
|
|
|
![]() |
| Thread Tools | |
|
|