Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 16th, 2006, 01:45 AM
Friend of Wrox
Points: 464, Level: 7
Points: 464, Level: 7 Points: 464, Level: 7 Points: 464, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2005
Location: Colombo, , Sri Lanka.
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nalla Send a message via Yahoo to nalla
Default java script


Hi,
how do we write a javascript function to add 2 numbers and call it in a command button click?


nalaka hewage
__________________
nalaka hewage
http://nalakahewage.blogspot.com
  #2 (permalink)  
Old June 18th, 2006, 11:53 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

create the function in the HTML

call it in the button click by adding an attribute in the Page_Load
button.attributes.add("onclick", "javascript:yourfucntion();")


  #3 (permalink)  
Old June 20th, 2006, 10:46 PM
Friend of Wrox
Points: 464, Level: 7
Points: 464, Level: 7 Points: 464, Level: 7 Points: 464, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2005
Location: Colombo, , Sri Lanka.
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nalla Send a message via Yahoo to nalla
Default


Thanx a lot.
can u please tell me what are the other events in textboxes and buttons that we can call java script functions by adding attributes.

Example :- button - OnClick
        :- Textbox - onBlur


nalaka hewage
  #4 (permalink)  
Old June 21st, 2006, 01:44 AM
Friend of Wrox
Points: 1,935, Level: 17
Points: 1,935, Level: 17 Points: 1,935, Level: 17 Points: 1,935, Level: 17
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2004
Location: United Kingdom
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi

We can call all the in-built events of the controls using Attributes.Add. Few examples are as below:

 - onblur
 - onchange
 - onclick
 - ondblclick
 - onfocus
 - onkeydown
 - onkeypress
 - onmousedown
 - onmouseup
 - onpropertychange



Regards
Mike
  #5 (permalink)  
Old June 21st, 2006, 07:49 AM
Friend of Wrox
Points: 464, Level: 7
Points: 464, Level: 7 Points: 464, Level: 7 Points: 464, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2005
Location: Colombo, , Sri Lanka.
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nalla Send a message via Yahoo to nalla
Default


hi,

I wrote a small javascript function to calculate a percentage by retrieving values 2 text boxes. it gives an error. can anybody tell me the reason for this error

Error:-
Microsoft JScript runtime error: 'document.form1.number2' is null or not an object

this is the line i got the error:-
theAnswer = ((document.form1.number2.value - document.form1.number1.value) / document.form1.number1.value * 100);

thanx




nalaka hewage
  #6 (permalink)  
Old June 22nd, 2006, 02:04 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hi Nalla!

plz check
1>document.form1.number2.value , might be you have different text field name.
2>document.form1.number2.value might be empty??
3>Always put check for the value exists or not before to perform arithmetic calculation
If possible put your form code,so that it may help us to figure out problem
Hope this will help you.


Cheers :)

vinod
  #7 (permalink)  
Old June 22nd, 2006, 11:29 PM
Friend of Wrox
Points: 464, Level: 7
Points: 464, Level: 7 Points: 464, Level: 7 Points: 464, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2005
Location: Colombo, , Sri Lanka.
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nalla Send a message via Yahoo to nalla
Default

Hi,
 I checked all 3 scenarios. those are alright. but I'm getting that error.



nalaka hewage
  #8 (permalink)  
Old June 23rd, 2006, 12:07 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii Nalla!!
plz check
<script>
function getValue()
{
theAnswer = ((document.form1.number2.value - document.form1.number1.value) / document.form1.number1.value * 100);
alert(theAnswer)
}
</script>
<form name=form1>
Number1<input type=text name=number1><br>
Number2<input type=text name=number2>
<br>
<input type=button onclick="getValue()" value="calculate" name=number22>
</form>

hope this will help you


Cheers :)

vinod
  #9 (permalink)  
Old June 23rd, 2006, 06:24 AM
Friend of Wrox
Points: 464, Level: 7
Points: 464, Level: 7 Points: 464, Level: 7 Points: 464, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2005
Location: Colombo, , Sri Lanka.
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nalla Send a message via Yahoo to nalla
Default




Thanx a lot Vinod.


nalaka hewage
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Script srkarthik_82 General .NET 0 December 28th, 2006 05:03 AM
Java Script arasu Javascript How-To 0 August 28th, 2006 01:28 AM
java Script raj1_syed Javascript How-To 1 August 17th, 2006 01:49 PM
java script madangcse@gmail.com Javascript How-To 1 March 22nd, 2006 04:10 AM
Java vs Java Script functions joemorrison74 J2EE 0 July 6th, 2005 04:28 PM



All times are GMT -4. The time now is 03:05 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.