www.webdeveloper.com
Results 1 to 4 of 4

Thread: Frustrated with listboxes in IE

  1. #1
    Join Date
    Jul 2004
    Location
    Canada
    Posts
    88

    Angry Frustrated with listboxes in IE

    I have this function that works perfectly well in Firefox but failes in IE. It's suppouse to read a text value of the option and then stick it into the hidden field.

    Any ideas how to make it work in both browsers ?

    Code:
    function agentNameFunc(){
            var agentNameVar=agent.options[agent.selectedIndex].text;
    	var campNameVar=project.options[project.selectedIndex].text;
    	document.getElementById("agentName").value=agentNameVar;
    	document.getElementById("projectName").value=campNameVar;
    }

  2. #2
    Join Date
    Dec 2004
    Posts
    8,637
    This assumes a certain default scoping:

    var agentNameVar=agent.options[agent.selectedIndex].text;

    Different browsers have a different default scoping depending upon the context.
    If you have a FORM tag then, cross-browser, the above should be as follows:

    var agentNameVar=document.myFormName.agent.options[document.myFormName.agent.selectedIndex].text;

  3. #3
    Join Date
    Jul 2004
    Location
    Canada
    Posts
    88
    thanks

  4. #4
    Join Date
    Dec 2004
    Posts
    8,637
    You're welcome.

    Cheers.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles