Click to See Complete Forum and Search --> : quote = very confusing


tiger66
07-03-2003, 08:35 PM
Hello
I am just wondering how can I use the variable in the onClick method which is outputting by javascript?

for example
function status1()
{
"<input type='radio' NAME='a' VALUE='AGC' onClick='status2(agc);' checked></td>"
}

function status2(type)
{
if(type=='agc'){
blah, blah...
}
}

I am getting a variable 'agc' undefined error message
I don't get it :(

when my onClick method is written in HTML like onClick="status2('agc')", it always recognized the variable 'agc'

I guess my question is when exactly do I need to use single quote and when do I need to use double quote?

Thanks for any help

Charles
07-04-2003, 05:25 AM
From the HTML 4.01 Specification:
By default, SGML requires that all attribute values be delimited using either double quotation marks (ASCII decimal 34) or single quotation marks (ASCII decimal 39). Single quote marks can be included within the attribute value when the value is delimited by double quote marks, and vice versa. Authors may also use numeric character references to represent double quotes (") and single quotes ('). For double quotes authors can also use the character entity reference &quot;.
http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2