Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Mar 2005
    Location
    Pakistan
    Posts
    207
    Thanks
    0
    Thanked 0 Times in 0 Posts

    works in Mozilla but not in IE

    <script>
    function copyvalue(){
    val=document.compose.receiver.value;
    val1=document.combo_box.list.options[document.combo_box.list.selectedIndex].value;
    if(val1!='' && val.indexOf(val1,0)== -1)
    document.compose.receiver.value+=val1+ ',';
    }
    </script>

    By this code, i m taking usernames of employees in a textbox to send message.
    God helps those who help others.

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,535
    Thanks
    3
    Thanked 513 Times in 500 Posts
    document.combo_box.list.selectedIndex]
    should be
    document.reciever.combo_box.list.selectedIndex]

    this will reduce you typos
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    
    <head>
      <title></title>
    <script>
    
    function copyvalue(f){
     val=f.receiver.value;
     val1=f.combo_box.options[f.combo_box.selectedIndex].value;
     if(val1!='' && val.indexOf(val1,0)== -1)
     document.compose.receiver.value+=val1+ ',';
    }
    
    </script>
    </head>
    
    <body>
    <form name="compose" >
    <select name="combo_box" onchange="copyvalue(this.form);">
    <option value="tom" >Tom</option>
    <option value="dick" >dick</option>
    <option value="harry" >harry</option>
    </select>
    <input name="receiver" size="50" >
    
    </form>
    </body>
    
    </html>


  •  

    Posting Permissions

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