HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 8th, 2004, 12:55 AM
tr333 tr333 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Location: Sydney, Australia
Posts: 44 tr333 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 58 sec
Reputation Power: 5
help with javascript & HTML DOM

hi,

I have a form that, when a button is clicked, it sends the info to a js function that is supposed to add the number "3" to the textbox on the form. Can someone please tell me what I should do to make it work...

Code:
<head>
  <script language="javascript">
  function fnNum(numText)
  {
  var x = document.myForm.num.value
  x = x + ""
  document.myForm.num.value=x+numText
  }
  </script>
  </head>
  
  <body>
  <form id="myForm">
  <input type="text" name="num">
  <button type="button" id="myButton" value="3" onClick="fnNum(this.value)">3</button>
  </form>
  </body>

Reply With Quote
  #2  
Old August 22nd, 2004, 10:08 PM
shamrog12's Avatar
shamrog12 shamrog12 is offline
Newton's Apple Wizard
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Nov 2003
Location: Los Angeles
Posts: 1,661 shamrog12 User rank is Sergeant Major (2000 - 5000 Reputation Level)shamrog12 User rank is Sergeant Major (2000 - 5000 Reputation Level)shamrog12 User rank is Sergeant Major (2000 - 5000 Reputation Level)shamrog12 User rank is Sergeant Major (2000 - 5000 Reputation Level)shamrog12 User rank is Sergeant Major (2000 - 5000 Reputation Level)shamrog12 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Weeks 2 Days 2 h 39 m 22 sec
Reputation Power: 34
Send a message via AIM to shamrog12
Code:
<head>
  <script language="javascript">
  function fnNum(intNumber) {
  var x = parseInt(document.myForm.num.value);
  x = x + parseInt(intNumber);
  document.myForm.num.value = x;
  }
  </script>
  </head>
  
  <body>
  <form id="myForm">
  <input type="text" id="num">
  <input type="hidden" id="numberToAdd" value="3">
  <input type="button" value="+? Button" id="numberButton" onClick="fnNum(document.myForm.numberToAdd.value)">
  </form>
  </body>
__________________
If you found a post of mine helpful, please click on the on my post to add to my reputation.


Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingHTML, JavaScript And CSS Help > help with javascript & HTML DOM


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway