Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 10th, 2004, 11:46 PM
Authorized User
 
Join Date: Apr 2004
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to pigtail Send a message via Yahoo to pigtail
Default onclick event

When I use onclick to execute a javascript:myfunctionname(), can I have more statements separated by a semi-colon after the colon or am I limited to only one statement after the colon?

If I want to pass an array, can I insert the array name between the ()? Sorry, I have asked this question in another entry. I didn't think of this possibility until now.

If I want to execute an ASP for my onclick and pass a string like "abc, efgh, ijklm", do I need a single quote around my values? What is the proper syntax?

Reply With Quote
  #2 (permalink)  
Old April 11th, 2004, 03:10 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Have you tried it?

Yes, you can. You could write a whole javascript program in a control's event handler attribute, assuming you can do so without needing to use the quote character that the attribute's value is enclosed in. You just need to separate the lines by a semi-colon:

<input type="button" onClick="alert('once');alert('twice');alert('three times a button');">

I've found you don't need to have the "javascript:" prefix in a handler attribute, but it's helpful when you use it in an <a> tag:

<a href="javascript:alert('hello');">click me</a>

You can pass anything you want to a javascript function. Any valid code including variables HTML controls, constants, strings, etc.

Remember that ASP is server side. Once you are in the context of running javascript you are in the browser so you can't run ASP code. You have to make a page request (post or get) for that.

Peter
-------------------------
Work smarter, not harder
Reply With Quote
Reply


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
DataGrid onclick event? hany ASP.NET 1.0 and 1.1 Professional 7 January 1st, 2006 05:21 AM
onclick event bjackman Access 6 July 15th, 2004 06:54 AM
onClick Event mateenmohd Javascript 4 December 16th, 2003 01:08 AM
onClick event problem mateenmohd Javascript 8 August 2nd, 2003 05:16 AM



All times are GMT -4. The time now is 02:08 AM.


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