SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict
    Join Date
    Dec 2001
    Location
    Market Harborough, UK
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    OnChange not working

    Hi,

    I have a web-based form which allows users to enter marks for a group of examination candidates. I have a function which performs some calculations on the data as it is entered and displays it immediately. The data-entry form-part definition is:-

    Code:
    <input size = "3" name="raw[91933]" value="" onchange="Javascript:recalc(91933);">
    Trouble is, recalc never seems to get called when I edit the text in the input!

    Anyone got any ideas?

    Paul
    Paul Simpson, BSc, MCNI, MCNE

  2. #2
    SitePoint Addict
    Join Date
    Dec 2001
    Location
    Market Harborough, UK
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ooops, typo up there, "java script" is all one word in my code!

    Paul
    Paul Simpson, BSc, MCNI, MCNE

  3. #3
    SitePoint Addict
    Join Date
    Aug 2001
    Location
    Los Angeles, CA
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you're looking for the OnFocus event...

  4. #4
    SitePoint Addict
    Join Date
    Dec 2001
    Location
    Market Harborough, UK
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But surely that will fire off when the user enters the textbox, not when they change it and leave? (I've tried OnBlur and that doesn't work either....)

    Paul
    Paul Simpson, BSc, MCNI, MCNE

  5. #5
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The onchange attribute is an event handler. Remove the "javascript:"
    Code:
    <input size = "3" name="raw[91933]" value="" onchange="recalc(91933)">

  6. #6
    SitePoint Addict
    Join Date
    Dec 2001
    Location
    Market Harborough, UK
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I now have
    Code:
    <input size = "3" name="raw[91933]" value="" onchange="recalc(91933)">
    but it still doesn't seem to work.

    As an aside, I have the "Javascript:" in the "OnChange" for some SELECT menus and that works...

    HELP!

    Paul
    Paul Simpson, BSc, MCNI, MCNE

  7. #7
    SitePoint Wizard davidjmedlock's Avatar
    Join Date
    Dec 2002
    Location
    Nashville, TN USA
    Posts
    1,688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any errors in your recalc() method? Do you get an error message or does it just not do anything at all?

  8. #8
    SitePoint Addict BenANFA's Avatar
    Join Date
    Apr 2003
    Location
    Bath, UK
    Posts
    353
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After a bit of experimentation it would appear that at least IE is not happy with the name recalc. I can not find any reason for this all I can say is that your code as specified did not work for me, but when I changed the function name to zcalc it all started working.

  9. #9
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah! Good work, BenANFA! I didn't know about that one.

    document.recalc


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
  •