SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Interesting Problem with grabbing values

    I have this:
    var selection = make.options[make.selectedIndex];
    in a function

    which basically takes the value selected from a drop-down, onchange.

    now the interesting thing is that when I have:
    <SELECT ID="make">
    <OPTION>1</OPTION>
    </SELECT>

    within <FORM></FORM> then this won't work:
    var selection = make.options[make.selectedIndex];

    and it says 'make' is undefined

    if it's not in the FORM tags then it works.

    Can you tell me why this happends? because I really need to have it within the FORM tags for submit

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Change it to
    var selection = frm.make.options[frm.make.selectedIndex].value;
    (if the form's id is "frm")

    "make" is undefined since it is not a "child" of "document"
    (explains why you can access it using only "make" if it's outside the form, but not inside)

    Navigator Object Hierarchy

  3. #3
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have so many thing in my mind. I was trying something like that but I was using the ID of the object instead of the form..bleh

    Thanx for that


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
  •