Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing arguments with single quotes

Status
Not open for further replies.

henslecd

MIS
Apr 21, 2003
259
US
I am trying to get the following line of code to work.

Code:
sSagList = "('31Z','32Z','31R','32R')"

document.write('<td class="list" style="padding-left:2px; font-weight:bold; border-right:0px solid #eeeeee">  <img style="cursor: default" onclick="AddRow(this,\'' + sSagList + '\');" alt="Insert Row" src="../graphics/returnarrow.gif" name="cmdInsert" id="cmdInsert">'+iRowCount+ ') ' + unescape(aNECRows[i].text) + '</td>');

I've replaced single quotes with double, double with single, etc etc. The following code works fine, except it doesn't have the second argument for the AddRow function.

Code:
document.write("<td class=list style='padding-left: 2px; font-weight: bold; border-right: 0px solid #eeeeee'><img style='cursor: default' onclick='AddRow(this);' alt='Insert Row' src='../graphics/returnarrow.gif' name='cmdInsert' id='cmdInsert'>&nbsp;&nbsp;&nbsp;&nbsp;" + iRowCount + ") " + unescape(aRows[i].text) + "</td>");

Is it possible to pass arguments with single quotes? The reason I need to pass the ('31Z','32Z','31R','32R') is because it will be used in a SQL WHERE clause;

WHERE BLAH in ('31Z','32Z','31R','32R')

Thanks for the help.
 
Is it necessary to write out what is in sSagList? Or is sSagList still available after the document.write so you can just reference it like this:
Code:
sSagList = "('31Z','32Z','31R','32R')"

document.write('<td class="list" style="padding-left:2px; font-weight:bold; border-right:0px solid #eeeeee">  <img style="cursor: default" onclick="AddRow(this,[b]sSagList[/b]);" alt="Insert Row" src="../graphics/returnarrow.gif" name="cmdInsert" id="cmdInsert">'+iRowCount+ ') ' + unescape(aNECRows[i].text) + '</td>');

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
If I do what you have mentioned, there is no javascript error when the page loads. But when I click on the image to set off AddRow() function, it says that sSagList is undefined.


Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top