By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,885 Members | 1,499 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,885 IT Pros & Developers. It's quick & easy.

Working with quotes and escape sequences

P: n/a
I have to put some html into a variable like so....

var html = '<TABLE cellspacing="5" border="0" .......

But within this html string I also need to have the code for a button
that traps the onclick method like so...

....<input type="button" name="Add Question" value="Repeat Question"
onclick="javascript:getQuestion( '3925','38497', '1' )" >....';

The problem is I am using double quotes for the onclick event and
single quotes for the variables. But I can not use single quotes becuz
the entire html variable is also under single quotes.

I am not sure how I can use escape sequences to help me here. Does
anyone have any suggestions?

Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

JehanN...@aol.com wrote:
I have to put some html into a variable like so....

var html = '<TABLE cellspacing="5" border="0" .......

But within this html string I also need to have the code for a button
that traps the onclick method like so...

...<input type="button" name="Add Question" value="Repeat Question"
onclick="javascript:getQuestion( '3925','38497', '1' )" >....';

The problem is I am using double quotes for the onclick event and
single quotes for the variables. But I can not use single quotes becuz the entire html variable is also under single quotes.

I am not sure how I can use escape sequences to help me here. Does
anyone have any suggestions?


'onclick="getQuestion(\'3925\',\'38497\', \'1\')" >';

Those are integers, you could just pass them as such.

'traps the onclick method' is inventive, but what you're doing is
registering an event handling function, assigning it to the onclick
property of that button. You can lose the javascript: (pseudo-)protocol
as well.

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.