SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to pass name parameters to function(id)

    i have a select box with a name but no id, and i want to call the function document.all() which takes an id as a parameter, how can i make it to take the name instead of the id.
    The reason my select does not take an id is because it is dynamically generated using Java.

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Do NOT use document.all. Instead of that document.getElementById() should be used. But, since you want to use the name, that doesn't seem optimal either - I think what you want is document.getElementsByName(). That will return a NodeList of all the elements that have the specified name. If there is only one element with the name, it'll be the first and only item in the list:
    Code:
    document.getElementsByName('thename').[0]

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <div onMouseover="if (document.all&&!window.opera){document.all('jump_menu').style.visibility='hidden'};" onMouseout="if (document.all&&!window.opera){document.all('jump_menu').style.visibility='visible'};">

    then how can i use the code above??

  4. #4
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Is that an attempt to detect Internet Explorer? Because if you use document.getElementsByName, then browsers like Mozilla will start to execute that javascript.

  5. #5
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually i wanna use explorer and nothing else

  6. #6
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <div onMouseover="document.getElementsByName('jump_menu')[0].style.visibility='hidden';" onMouseout="document.getElementsByName('jump_menu')[0].style.visibility='visible';">


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
  •