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 8 of 8
  1. #1
    Banned
    Join Date
    Jan 2012
    Posts
    93
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Having braking problems

    Does anyone know how I can stop this error?
    PHP Code:
    if ($row['size30'] > 0) {
        echo 
    '
            if (document.forms["form"]["quantity"].value > '
    .$row['size30'].') {
                alert ("Can'
    t add because quantity exceeds availability.");
                return false;
            }
        ';

    The problem is with the apostrophe in the word Can't. Its causing a braking out issue.

  • #2
    Banned
    Join Date
    Jan 2012
    Posts
    93
    Thanks
    8
    Thanked 0 Times in 0 Posts
    A cheap method:

    PHP Code:
    if ($row['size30'] > 0) {
        echo 
    '
            if (document.forms["form"]["quantity"].value > '
    .$row['size30'].') {
                alert ("Can'
    ; echo "'"; echo 't add because quantity exceeds availability.");
                return false;
            }
        '
    ;

    Anyone know a [strike]more[/strike] professional method?

  • #3
    Banned
    Join Date
    Jan 2012
    Posts
    93
    Thanks
    8
    Thanked 0 Times in 0 Posts
    You know what, who cares it works.

    Resolved.

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    The simpler solution would be to replace Can't with Can\'t
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • Users who have thanked felgall for this post:

    JudgementDay (02-19-2012)

  • #5
    Banned
    Join Date
    Jan 2012
    Posts
    93
    Thanks
    8
    Thanked 0 Times in 0 Posts
    That didn't work.

  • #6
    Banned
    Join Date
    Jan 2012
    Posts
    93
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Not so, the problem lays else where... I shall report.

  • #7
    Banned
    Join Date
    Jan 2012
    Posts
    93
    Thanks
    8
    Thanked 0 Times in 0 Posts
    It was working, but the script wasn't being triggered due to an associated name error.

  • #8
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,344
    Thanks
    13
    Thanked 349 Times in 345 Posts
    Quote Originally Posted by JudgementDay View Post
    Anyone know a [strike]more[/strike] professional method?
    if there are too many 's and "s, I check whether I can use the HEREDOC syntax.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer


  •  

    Posting Permissions

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