Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder
    Join Date
    May 2004
    Posts
    1,464
    Thanks
    15
    Thanked 0 Times in 0 Posts

    semi colon in javascript var

    I have the following code:

    PHP 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?

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Edinburgh, UK
    Posts
    402
    Thanks
    2
    Thanked 1 Time in 1 Post
    Might also be the fact you haven't escaped the " sign and you're missing an > character:

    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>";
    Rich

    "An expert is a person who has made all the mistakes that can be made in a very narrow field."

  • #3
    New Coder
    Join Date
    Feb 2005
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    type a \ before the " or any other character that is an invalid syntax.

    eg.

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

  • #4
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    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.

    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>';
    Basscyst
    Last edited by Basscyst; 02-12-2005 at 05:44 PM.
    Helping to build a bigger box. - Adam Matthews


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •