dcsimg
www.webdeveloper.com
Results 1 to 7 of 7

Thread: Works in Netscape but malfunction in IE...

  1. #1
    Join Date
    Mar 2004
    Posts
    9

    Unhappy Works in Netscape but malfunction in IE...

    Hello everbody,

    Good day! I'm new here...

    I did some coding in HTML and which will call-up the following JS by click on a selection-box(listed below).

    In Netscape, it works fine but in IE it fails to return the list (in string) of clicked items from the slection box...

    Would somebody could give a hand on it and show me where is the error and solution? Thank you very very much! :>

    Cheers,
    Arnold

    ========
    html code:
    ....
    <select name="BengProg" size="4" multiple id="select3" style="width:400px" onclick="Pullhigh(1);outputSelected(document.form1.BengProg.options,1)">
    ....
    <select name="MstrProg" size="4" style="width:400px" multiple onclick="Pullhigh(3);outputSelected(document.form1.MstrProg.options,2)">
    ....
    ========
    function getSelected(opt) {
    var selected = new Array();
    var index = 0;
    for (var intLoop = 0; intLoop < opt.length; intLoop++) {
    if ((opt[intLoop].selected) ||
    (opt[intLoop].checked)) {
    index = selected.length;
    selected[index] = new Object;
    selected[index].value = opt[intLoop].value;
    selected[index].index = intLoop;
    }}return selected;
    }
    function outputSelected(opt,oploc) {
    var i=0;
    var sel = getSelected(opt);
    var strSel = "";
    for (var item in sel){
    strSel += sel[item].value + ","; i++;
    } strSel = i+","+strSel;
    document.form1.checkboxAct.value=checkboxAct;
    if (oploc==1){
    document.form1.BengProg_list.value=strSel;}
    if (oploc==2){
    document.form1.MstrProg_list.value=strSel;}
    alert (strSel);
    }

  2. #2
    Join Date
    Nov 2003
    Location
    Aachen, Germany
    Posts
    4,090
    Hi!

    Assuming that the rest of your code (the part, you didn't post here) is correct I can say, that if you add the same stuff, which you have for onClick= in your selects also as onChange= IE will be able to deal with it and your script would not disturb Mozilla...

    Cheers - Pit

  3. #3
    Join Date
    Mar 2004
    Posts
    9

    Smile

    Hi,

    Thanks for you reply!

    I had tried to use onChange= and IE could return the number of picked item, but it still can give me the contents in the array...
    BTW, please to go the following URL for a trial...

    Again, in Netscape, it works...(it return the number of picked items Plus which item was being clicked) but in IE ... :<

    http://home.ust.hk/~egitc/Kozue/Java_Questioning.htm

    Thank you again!
    Cheers.

  4. #4
    Join Date
    Mar 2004
    Posts
    9
    oh....typo error

    IE could return the number of picked item, but it still CAN'T give me the contents in the array...

  5. #5
    Join Date
    Nov 2003
    Location
    Aachen, Germany
    Posts
    4,090
    Hi!

    The problem with your code is not in onclick or onchange!

    IE doesn't recognize the option's values because it is too stupid to recognize the alternative, if no value is there, whereas Mozilla does.

    You do not assign values to your options, only the clickable text. If you change only one word in your code, both IE and Mozilla will be satisfied:

    function getSelected(opt) {
    var selected = new Array();
    var index = 0;
    for (var intLoop = 0; intLoop < opt.length; intLoop++) {
    if ((opt[intLoop].selected) ||
    (opt[intLoop].checked)) {
    index = selected.length;
    selected[index] = new Object;
    selected[index].value = opt[intLoop].text;
    selected[index].index = intLoop;
    }}return selected;
    }

    Cheers - Pit

  6. #6
    Join Date
    Mar 2004
    Posts
    9

    Thumbs up

    Hi,

    Cool~~~

    Thank you so much!

    Cheers
    Arnold

  7. #7
    Join Date
    Nov 2003
    Location
    Aachen, Germany
    Posts
    4,090

    Cool

    Hi!

    You're welcome!!

    Cheers - Pit

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