SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2004
    Location
    Manchester
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Expersion spanning two lines so not working.

    I have the following code in my page :

    Code:
    <input type="image" src="../images/add.gif" name="id<% = rs("code_no")%>add" value="<%=txt_add%>" onClick="top.center.cart.addItem('<% = rs("item")%>','<% = rs("price")%>', document.itemsform.id<% = rs("code_no")%>quant.value, document.itemsform.id<% = rs("code_no")%>number.value, '<% =rs("shipping")%>'); return false;">
    This is all on one line in my editor but when the page is run it puts it on two lines so the browser throws an error up saying unterminated expression and looks like this...

    Code:
    <input type="image" src="../images/add.gif" name="id470038add" value="Add to Cart" onClick="top.center.cart.addItem('Body Butter 1oz - Lemon Crème','5.95', document.itemsform.id470038quant.value, document.itemsform.id470038number.value, '2.55
    '); return false;">
    It is reading the '2.55 and not ending the expression due to the new line. If I take out the shipping it is fine. Can anyone tell me why it's putting it on a new line and how to stop it please.

    Thanks

  2. #2
    SitePoint Wizard silver trophy rushiku's Avatar
    Join Date
    Dec 2003
    Location
    A van down by the river
    Posts
    2,056
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    my first guess would be that there's a line return after the rs("shipping") value 2.55.

  3. #3
    SitePoint Addict Guimauve's Avatar
    Join Date
    Aug 2004
    Location
    Chicago
    Posts
    255
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why don't you just break it onto two lines yourself instead, that way you control where the break takes place. This also makes the code easier to read:
    Code:
    <input type="image" src="../images/add.gif"
    name="id470038add" value="Add to Cart"
    onClick="top.center.cart.addItem('Body Butter 1oz - Lemon Crème','5.95', document.itemsform.id470038quant.value, document.itemsform.id470038number.value, '2.55'); return false;">
    Charles

  4. #4
    SitePoint Wizard silver trophy rushiku's Avatar
    Join Date
    Dec 2003
    Location
    A van down by the river
    Posts
    2,056
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    My previous statement may have been a little dubious...

    I suspect that the value '2.55' actually is '2.55\n' where ever it is stored.

    The line breaks just after an inserted value, at column 243. I don't know where, or if, different parsers insert line breaks, but I doubt column 243 is a choice any programmer out there made.


Bookmarks

Posting Permissions

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