Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Passing data to another function inside a function
Old 02-03-2010, 01:17 AM Passing data to another function inside a function
Junior Talker

Posts: 2
Name: aaaaaaaa
Trades: 0
Hi,

Any one help me

In one variable i have some data ex: var data = document.getElementById("imageId").value;

I want to pass this data to another function inside another function ex:

var button1 = '<img src="images/Remove-button.gif" width="70" height="15" onclick="removeVerifyImageRow(this),saveLibData('+ data+')"/>';

while running the application i am getting an error incase if the data is string ex:if data is 'image1' i am getting an error, but with number there is no problem ex: if data is '1122'.

this is very urgent to solve this problem plz any one help me
aaaaaaaa is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-03-2010, 10:14 AM Re: Passing data to another function inside a function
css
Novice Talker

Posts: 6
Trades: 0
saveLibData(\''+ data+'\')
css is offline
Reply With Quote
View Public Profile
 
Old 02-03-2010, 10:38 AM Re: Passing data to another function inside a function
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
You need to "escape" the quote marks in the string to make them be "literals"

Code:
var button1 = '<img src=\"images/Remove-button.gif\" width=\"70\" height=\"15\" onclick=\"removeVerifyImageRow(this),saveLibData(' + data + ')\"/>';
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 02-05-2010, 12:58 AM Re: Passing data to another function inside a function
Junior Talker

Posts: 2
Name: aaaaaaaa
Trades: 0
I tried in your approach also but that also not working i am getting the same error as entered data is undefined ('image1' is undefined)
aaaaaaaa is offline
Reply With Quote
View Public Profile
 
Old 02-05-2010, 07:10 AM Re: Passing data to another function inside a function
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Whoo Hoo! we get to know what the error is!!

Now we get to see ALL THE CODE???

what you provided up to now is passing a STRING of HTML . At a guess (due to the error message) the function is expecting a REFERENCE to an image object or the name attribute or id attribute value of an image object

We cannot guess at what you are doing incorrectly if we only get part of the problem.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Passing data to another function inside a function
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.27607 seconds with 12 queries