#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2006
    Posts
    33
    Rep Power
    13

    Inline if problem


    I am trying to use the inline if statement to either run some functions or do nothing after a validation.

    here is the code:
    Code:
    onchange="(isNumeric('quality','processedPercent_display'))?'document.quality.processedPercent.value = this.value;getValues('quality',4);setDisplay('quality','processedPercent_display','percent')':'';"
    basically, if the IsNumeric return 'true' do the rest of the javascript, if it is returned false do nothing.

    This bit of code is in a html input tag.

    I can't seem to get it work. any help would be greatly appreciated.
  2. #2
  3. Autodidact
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2008
    Location
    Canada
    Posts
    741
    Rep Power
    837
    Is this approach required? Regardless, the string is not formatted correctly; there are single quotation marks that need to be escaped.
    Soldiers, from the height of these pyramids forty centuries look down upon you.
    ▪ Napoleon, on the eve of the Battle of the Pyramids
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2006
    Posts
    33
    Rep Power
    13
    well, i have had to squeeze a lot of javascript into my html onchange for a number of reason which i'm not getting into.

    I changed the code anyway.

    Code:
    onchange="if(isNumeric('quality','processedPercent_display')){document.quality.processedPercent.value = this.value;getValues('quality',4);setDisplay('quality','processedPercent_display','percent');}'';">
    I just added the if statement, and it works exactly how I want it to.

IMN logo majestic logo threadwatch logo seochat tools logo