Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how delete optgroup

Status
Not open for further replies.

fuadhamidov

Programmer
Sep 22, 2003
98
TR
hi

how can i delete optgroup with javascript. or how i can get length of optgroup

the code bellow can only drop the optoins not optgroups
Code:
    while ( 0 < document.form.SENDMESSAGE.options.length ) {
        document.form.SENDMESSAGE.remove( 0 );
    }

thanks for any help
 
>>optgroup???i have never heard of one before.
does it reffer to a <select> field???

Known is handfull, Unknown is worldfull
 
yes
try this

Code:
<select name="ALLUSER" multiple style="font-family: Verdana; font-size: 8pt; width: 200; height: 250; border: 1px solid #C0C0C0">
<optgroup label='Test1'>
  <option value="0-1">aaa</option>
  <option value="0-2">bbb</option>
  <option value="0-3">ccc</option>
  <option value="0-4">ddd</option>
</optgroup>
<optgroup label='Test2'>
  <option value="1-1">eee</option>
  <option value="1-9">fff</option>
  <option value="1-10">ggg</option>
  <option value="1-11">hhh</option>
</optgroup>
</select>
 
thanks glen,
i will check on this and comeback...

Known is handfull, Unknown is worldfull
 
try this:
Code:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
function RemoveOpt(TheOptGroup)
{
	TheOpt=document.getElementById(TheOptGroup)
	TheParent=TheOpt.parentNode
	TheParent.removeChild(TheOpt)
}
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<form name="Frm">
<select name="ALLUSER" onchange="RemoveOpt('Test1')">
<optgroup label='Test1' id='Test1'>
  <option value="0-1">aaa</option>
  <option value="0-2">bbb</option>
  <option value="0-3">ccc</option>
  <option value="0-4">ddd</option>
</optgroup>
<optgroup label='Test2' id='Test2'>
  <option value="1-1">eee</option>
  <option value="1-9">fff</option>
  <option value="1-10">ggg</option>
  <option value="1-11">hhh</option>
</optgroup>
</select>
</form>
</body>
</html>

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top