SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Hybrid View

  1. #1
    SitePoint Evangelist goughb's Avatar
    Join Date
    Sep 2000
    Location
    Chicago
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Adding onBlur to dynamic textfield

    Hey,

    Ok so I am creating an element with:

    PHP Code:
    var newElement document.createElement('INPUT'); 
    Then I assign the properties:

    PHP Code:
    with (newElement)
    {
         
    name "adjustmentCost" count;
         
    size 7;
         
    maxlength 8
         
    onblur "alert();"//This doesn't seem to work

    adding onblur in the properties above doesn't work.. I also can't seem to do this:
    PHP Code:
    document.getElementsByName("ELEMENTNAME").onblur "javascript:alert();"
    Any suggestions on what I am doing wrong?

    Thanks,

    Brett

  2. #2
    morphine for a wooden leg randem's Avatar
    Join Date
    Jun 2002
    Location
    .chicago.il.us
    Posts
    957
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    with (newElement)
    {
         name = "adjustmentCost" + count;
         size = 7;
         maxlength = 8; 
         onblur = new Function("alert('Foo!');");
    }
    ----Adopt-a-Sig----
    Your message here!

  3. #3
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    normally you have to open a reference handle location for
    an event handler, unless you're calling an existing function,
    without parameters - in which case you can probably do it with:

    object.onblur = callFunc

    Notice the lack of ();

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  4. #4
    SitePoint Evangelist goughb's Avatar
    Join Date
    Sep 2000
    Location
    Chicago
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, but I am trying to call an existing function with one parameter which is normally looks like this:
    onblur='checkFloat(this)' - when placed in the input type='text' element. How should I do this?

    Brett

  5. #5
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    randem's answer is right for you then.
    you need to initiate a new memory space for the function.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  6. #6
    SitePoint Evangelist goughb's Avatar
    Join Date
    Sep 2000
    Location
    Chicago
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So I need to rewrite the function in one line?

    Brett

  7. #7
    SitePoint Evangelist goughb's Avatar
    Join Date
    Sep 2000
    Location
    Chicago
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    rrrr, nm.. I see.. Thank you!..

  8. #8
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


    Clarity with time!

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


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
  •