SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Jul 2007
    Posts
    233
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    onChange problem when deleting <input> value

    Greetings,

    I have something like this:
    PHP Code:
    <input type="text" name="country" value="<?php echo $country?>" onchange="SaveCountry(this.value);" />
    Basically when someone types in a country, the onchange will run an AJAX function and saves the country name to the database.

    The problem I'm having is when someone goes back to this input later and tries to delete the country, the onchange function will not work. It works perfectly except when someone tries to totally delete the field. I am guessing it has something to do with a blank value.

    Let me know if there is a way to deal with this.

    Thanks

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,682
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by peppy View Post
    The problem I'm having is when someone goes back to this input later and tries to delete the country, the onchange function will not work.
    It seems to work for me. Do you have a test page that demonstrates the problem, so that further troubleshooting can be done from there?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


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
  •