...

View Full Version : semi colon in javascript var



esthera
01-19-2005, 11:34 AM
I have the following code:




modifications5="<select name=mods5 class=typo><option value=None SELECTED >None</option><option value=335!Standard>5'-PO4 abcd</option><option value=340!RP-abc>5'-xdddAmino</option><option value=343!Standard>5" Abc C6</option</select>";


This returns an error I assume becaue I have both the semi colon and colon within the text. What is the way around this?

Badman3k
01-19-2005, 01:02 PM
Might also be the fact you haven't escaped the " sign and you're missing an > character:



modifications5="<select name=mods5 class=typo><option value=None SELECTED >None</option><option value=335!Standard>5'-PO4 abcd</option><option value=340!RP-abc>5'-xdddAmino</option><option value=343!Standard>5\" Abc C6</option></select>";

Bolter99
02-12-2005, 06:50 AM
type a \ before the " or any other character that is an invalid syntax.

eg.

var example = "Text \"text\" TEXT";

Basscyst
02-12-2005, 06:41 PM
When working with an HTML string, you always want to open your string with a single quote. This allows you to use double quotes for the html attributes, which is more proper, and you have left out in your example. Also note, that you should always use lowercase for your tags and attributes.



modifications5='<select name="mods5" class="typo">'+
'<option value="None" selected>None</option>'+
'<option value="335!Standard">5\'-PO4 abcd</option>'+
'<option value="340!RP-abc">5\'-xdddAmino</option>'+
'<option value="343!Standard">5" Abc C6</option>'+
'</select>';


Basscyst



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum