Welcome visitor
* Login
* Register
It is currently September 21st, 2019, 2:16 am
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Client Side » JavaScript



Post new topic Reply to topic  [ 4 posts ] 
Author Message
  send 2 variables into a javascript function
PostPosted: July 26th, 2009, 2:23 am 

Posts: 39
i know this is going to be a very simple thing but how can i pass 2 variables into a javascript function?


Top
 Profile  
 
  Re: send 2 variables into a javascript function
PostPosted: July 26th, 2009, 2:37 am 
User avatar

Posts: 79
use commas to separate them
onclick="functionOfyours(value1,value2);"

and on the function declare two variables, one for each value
function functionOfyours(var1,var2){
document.write(var1+var2);}


Top
 Profile  
 
  Re: send 2 variables into a javascript function
PostPosted: July 26th, 2009, 2:43 am 

Posts: 39
thanks but why doi get this error?
Quote:
value1 is not defined


Top
 Profile  
 
  Re: send 2 variables into a javascript function
PostPosted: July 26th, 2009, 2:57 am 
User avatar

Posts: 79
value1 was an example, it should be 'value1'. if you write only value1, value1 is considered to be a variable. for example, id is already a variable, so if you send it you will not need quotation mark:
<img id="pic1" src="image.jpg" onclick="resize(id,800,400);">
note that 800 and 400 arent quoted either, that is because they are numbers and not variables.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

FORUMS » Client Side » JavaScript


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron