Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion How to select Muntliple input to remove from the list
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Pervez Mulla  
View profile  
 More options Oct 1 2012, 5:14 am
Newsgroups: comp.lang.javascript
From: Pervez Mulla <mullaper...@gmail.com>
Date: Mon, 1 Oct 2012 02:14:15 -0700 (PDT)
Local: Mon, Oct 1 2012 5:14 am
Subject: How to select Muntliple input to remove from the list
Hi,

I have the code , which add the data from input filed to list-box.Now am able to remove individual input's.

I want to have option multiple select to remove the data from list box  .
<form id="frm" action="" method="post">
  Select list:<br/>
  <select name="sel_list" id="sel_list" size="2" onchange="adOption.selOpt(this.value, 'optval')"></select><br/><br/>
  Add an option: <input type="text" name="optval" id="optval" /><br /><br/>
  <input type="button" id="addopt" name="addopt" value="Add Option" onclick="adOption.addOption('sel_list', 'optval');" /> &nbsp;
  <input type="button" id="del_opt" name="del_opt" value="Delete Option" onclick="adOption.delOption('sel_list', 'optval');" />
</form>
<script type="text/javascript"><!--
var adOption = new Object();
  adOption.checkList = function(list, optval) {
    var re = 0;      
    var opts = document.getElementById(list).getElementsByTagName('option');

    for(var i=0; i<opts.length; i++) {
      if(opts[i].value == document.getElementById(optval).value) {
        re = 1;
        break;
      }
    }
    return re;    
   };
  adOption.addOption = function(list, optval) {
    var opt_val = document.getElementById(optval).value;
    if(opt_val.length > 0) {
      if(this.checkList(list, optval) == 0) {
        var myoption = document.createElement('option');
        myoption.value = opt_val;
        myoption.innerHTML = opt_val;
        document.getElementById(list).insertBefore(myoption, document.getElementById(list).firstChild);

        document.getElementById(optval).value = '';  
      }
      else alert('The value "'+opt_val+'" already added');
    }
    else alert('Add a value for option');
  };
  adOption.delOption = function(list, optval) {
    var opt_val = document.getElementById(optval).value;
    if(this.checkList(list, optval) == 1) {
      var opts = document.getElementById(list).getElementsByTagName('option');
      for(var i=0; i<opts.length; i++) {
        if(opts[i].value == opt_val) {
          document.getElementById(list).removeChild(opts[i]);
          break;
        }
      }
    }
    else alert('The value "'+opt_val+'" not exist');
  }
  adOption.selOpt = function(opt, txtbox) { document.getElementById(txtbox).value = opt; }
--></script>

How can I do this ....?
Please Help

Thank You
Pervez


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.