Which is correct?

  • Thread starter Thread starter Nelson Smith
  • Start date Start date
N

Nelson Smith

In my java script to set the value I am using the following code

document.frmMyForm.txtCustNo.value = "xxxxx"

&

document.frmMyForm.txtCustNo.value = 'xxxxx'



Questions is single quote or double quote is right way coding?

Thanks,

Nelson
 
either is fine. it just a matter of preference. single quotes are handy when
javascript is imbeeded in html:

<button onclick="doProcess(this,'someLiteral');">

or if the javascript outputs html which contains quotes.

document.write('<img src="images/foo.gif">');

-- bruce (sqlwork.com)
 
What is the professional way of doing it?

The professional way of doing it is thus:

1. Understand the rules of HTML.
2. Know what your options are.
3. Use the method that is most appropriate at the time.
4. If neither is more appropriate, pick one.

You can take my word for it. I'm a professional. ;-)

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Well, you CAN escape double-quotes. But it is more time-consuming to do so.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Back
Top