www.webdeveloper.com
Results 1 to 3 of 3

Thread: remove a selected item from options

  1. #1
    Join Date
    Dec 2012
    Posts
    4

    remove a selected item from options

    I need to remove top item from right column.

    Tried from link "http://www.mredkj.com/tutorials/tutorial005.html"

    Question :

    1 how to I refresh screen to show new set of values. ( Currently for me it shows old values.)
    2 After sorting, values change. How do i remove current top value.




    Code:
    				<div class="selectTask">
    					<form name="TaskList" method="post" action="TaskList.asp">
    						<select name="searchable[]" id='searchable' multiple='multiple'>
    							<?php foreach( $output as $each ): ?>
    							<?php $var++?>
    							<option value="$var"><?=$each?></option>
    							<?php endforeach; ?>
    						</select>
    					</form>
    				</div>

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,412

    Lightbulb

    Don't know if it applies to PHP, but since this is the JS forum
    this is how it might be done here...
    Code:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8" />
    
    <title> HTML5 page </title>
    
    </head>
    <body>
    <select  id="SBox">
      <option value=""> Select </option>
      <option value="1"> 1 </option>
      <option value="2"> 2 </option>
      <option value="3"> 3 </option>
      <option value="4"> 4 </option>
    </select>
    <button onclick="removeSBoxOption('SBox')">Remove top</button>
    <script type="text/javascript">
    function removeSBoxOption(IDS) {
      obj = document.getElementById(IDS);
      if (obj.options.length > 0) { obj.options[0].remove(); }
    }
    </script>
    
    </body>
    </html>

  3. #3
    Join Date
    Jun 2014
    Posts
    7
    Yes, It has been removed all.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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