hi avner,
i want to remove the option from the added course when user click 'drop'.
u have any idea how?
yazi
Main Topics
Browse All Topicshi,
anyhow know how to deselect the options value from a select box?
here i have 2 multiple select box, when i click 'add', it will added to second select box. Now my problem is how deselect the second option when user click a 'drop' button.
<html>
<head>
<link rel="StyleSheet" href="style.css" type="text/css" />
<title>Add Courses</title>
<script language="JavaScript">
<!--
function populateForm() {
for (var Current=0;Current < document.courseform.course
if (document.courseform.cours
var defaultSelected = true, selected = true;
var optionName = new Option(document.courseform
if (replacedfirst)
var length = document.courseform.addedc
else
var length = 0;
document.courseform.addedc
replacedfirst = true;
}
}
}
var replacedfirst = false;
//-->
</script>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<form name="courseform" onSubmit="return false;">
<tr>
<td width="100%" colspan="3" class="Title">Course Selection</td>
</tr>
<tr>
<td width="17%"> </td>
<td width="83%" colspan="2"> </td>
</tr>
<tr>
<td width="17%" valign="top">Available Courses</td>
<td width="19%">
</p>
</td>
<td width="64%">
<p align="left">Added Courses</td>
</tr>
<tr>
<td width="20%">
<select size="10" name="course" multiple>
<option selected value="COMM3604 Systems Analysis & design">COMM3604 Systems Analysis & design</option>
<option value="COMP3201 Computer Graphics">COMP3201 Computer Graphics</option>
<option value="COMP3202 Modelling and Visualisation">COMP3202 Modelling and Visualisation</option>
<option value="COMP3300 Operating Systems">COMP3300 Operating Systems</option>
<option value="COMP3400 Models of Programming & Computation">COMP3400 Models of Programming & Computation</option>
<option value="COMP3401 Compilers & Interpreters">COMP3401 Compilers & Interpreters</option>
<option value="COMP3402 Concurrent & Real-Time Systems">COMP3402 Concurrent & Real-Time Systems</option>
<option value="COMP3500 The Software Process">COMP3500 The Software Process</option>
<option value="COMP3501 Human-Computer Interaction">COMP3501 Human-Computer Interaction</option>
<option value="COMP3502 Information Security">COMP3502 Information Security</option>
<option value="COMP3503 Interaction Design">COMP3503 Interaction Design</option>
<option value="COMP3600 Reasoning about Software">COMP3600 Reasoning about Software</option>
<option value="COMP3601 Software Specification">COMP3601 Software Specification</option>
<option value="COMP3701 Principles of Artificial Intelligence">COMP3701 Principles of Artificial Intelligence</option>
<option value="COMP3804 Information Technology Project">COMP3804 Information Technology Project</option>
<option value="COMS3200 Computer Networks I">COMS3200 Computer Networks I</option>
<option value="INFS3100 Introduction of Information Science">INFS3100 Introduction of Information Science</option>
<option value="INFS3200 Advanced Database Systems">INFS3200 Advanced Database Systems</option>
<option value="INFS3202 Web Information Systems">INFS3202 Web Information Systems</option>
</select> </td>
<td width="19%" align="center">
<input type="submit" value=" Add " name="add " onClick="populateForm();">
<input type="submit" value="Drop" name="drop"></td>
<td width="64%" valign="top">
<p align="left">
<select size="4" name="addedcourse">
<option value="">
</select></td>
</tr>
<tr>
<td width="17%"> </td>
<td width="19%" align="center"> </td>
<td width="64%"> </td>
</tr>
<tr>
<td width="17%"> </td>
<td width="19%" align="center">
<p align="right"> </td>
<td width="64%"> </td>
</tr>
<tr>
<td width="17%" valign="Top"> </td>
<td width="19%" align="center">
</td>
<td width="64%">
<p align="center">
<input type="submit" value="Submit" name="submit" style="float: right"></td>
</tr>
<tr>
<td width="17%"> </td>
<td width="19%" align="center">
</td>
<td width="64%">
</td>
</tr>
<tr>
<td width="17%"> </td>
<td width="19%" align="center">
</td>
<td width="64%">
</td>
</tr>
</form>
</table>
</body>
</html>
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Here you go:
<html>
<head>
<link rel="StyleSheet" href="style.css" type="text/css" />
<title>Add Courses</title>
<script language="JavaScript">
<!--
function populateForm() {
for (var Current=0;Current < document.courseform.course
if (document.courseform.cours
var defaultSelected = true, selected = true;
var optionName = new Option(document.courseform
if (replacedfirst)
var length = document.courseform.addedc
else
var length = 0;
document.courseform.addedc
replacedfirst = true;
}
}
}
function removeCourse(){
var objFormField = document.courseform.addedc
intSelected = objFormField.selectedIndex
objFormField.options[intSe
}
var replacedfirst = false;
//-->
</script>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<form name="courseform" onSubmit="return false;">
<tr>
<td width="100%" colspan="3" class="Title">Course Selection</td>
</tr>
<tr>
<td width="17%"> </td>
<td width="83%" colspan="2"> </td>
</tr>
<tr>
<td width="17%" valign="top">Available Courses</td>
<td width="19%">
</p>
</td>
<td width="64%">
<p align="left">Added Courses</td>
</tr>
<tr>
<td width="20%">
<select size="10" name="course" multiple>
<option selected value="COMM3604 Systems Analysis & design">COMM3604 Systems Analysis & design</option>
<option value="COMP3201 Computer Graphics">COMP3201 Computer Graphics</option>
<option value="COMP3202 Modelling and Visualisation">COMP3202 Modelling and Visualisation</option>
<option value="COMP3300 Operating Systems">COMP3300 Operating Systems</option>
<option value="COMP3400 Models of Programming & Computation">COMP3400 Models of Programming & Computation</option>
<option value="COMP3401 Compilers & Interpreters">COMP3401 Compilers & Interpreters</option>
<option value="COMP3402 Concurrent & Real-Time Systems">COMP3402 Concurrent & Real-Time Systems</option>
<option value="COMP3500 The Software Process">COMP3500 The Software Process</option>
<option value="COMP3501 Human-Computer Interaction">COMP3501 Human-Computer Interaction</option>
<option value="COMP3502 Information Security">COMP3502 Information Security</option>
<option value="COMP3503 Interaction Design">COMP3503 Interaction Design</option>
<option value="COMP3600 Reasoning about Software">COMP3600 Reasoning about Software</option>
<option value="COMP3601 Software Specification">COMP3601 Software Specification</option>
<option value="COMP3701 Principles of Artificial Intelligence">COMP3701 Principles of Artificial Intelligence</option>
<option value="COMP3804 Information Technology Project">COMP3804 Information Technology Project</option>
<option value="COMS3200 Computer Networks I">COMS3200 Computer Networks I</option>
<option value="INFS3100 Introduction of Information Science">INFS3100 Introduction of Information Science</option>
<option value="INFS3200 Advanced Database Systems">INFS3200 Advanced Database Systems</option>
<option value="INFS3202 Web Information Systems">INFS3202 Web Information Systems</option>
</select> </td>
<td width="19%" align="center">
<input type="submit" value=" Add " name="add " onClick="populateForm();">
<input type="submit" value="Drop" name="drop" onClick = "removeCourse()"></td>
<td width="64%" valign="top">
<p align="left">
<select size="4" name="addedcourse">
<option value="">
</select></td>
</tr>
<tr>
<td width="17%"> </td>
<td width="19%" align="center"> </td>
<td width="64%"> </td>
</tr>
<tr>
<td width="17%"> </td>
<td width="19%" align="center">
<p align="right"> </td>
<td width="64%"> </td>
</tr>
<tr>
<td width="17%" valign="Top"> </td>
<td width="19%" align="center">
</td>
<td width="64%">
<p align="center">
<input type="submit" value="Submit" name="submit" style="float: right"></td>
</tr>
<tr>
<td width="17%"> </td>
<td width="19%" align="center">
</td>
<td width="64%">
</td>
</tr>
<tr>
<td width="17%"> </td>
<td width="19%" align="center">
</td>
<td width="64%">
</td>
</tr>
</form>
</table>
</body>
</html>
Fritz the Blank
This is much trickier than it sounds, but I think I have it:
<html>
<head>
<link rel="StyleSheet" href="style.css" type="text/css" />
<title>Add Courses</title>
<script language="JavaScript">
<!--
function populateForm() {
for (var Current=0;Current < document.courseform.course
if (document.courseform.cours
var defaultSelected = true, selected = true;
var optionName = new Option(document.courseform
if (replacedfirst)
var length = document.courseform.addedc
else
var length = 0;
document.courseform.addedc
replacedfirst = true;
}
}
}
function removeCourse(){
var arrKeep = new Array();
var intArrayIndex = 0
var objFormField = document.courseform.addedc
for(i=0;i<objFormField.len
if(!objFormField[i].select
arrKeep[intArrayIndex] = objFormField[i].text;
intArrayIndex++;
}
}
objFormField.length=0;
for(i=0;i<arrKeep.length;i
objFormField[i] = new Option(arrKeep[i],arrKeep[
}
}
var replacedfirst = false;
//-->
</script>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<form name="courseform" onSubmit="return false;">
<tr>
<td width="100%" colspan="3" class="Title">Course Selection</td>
</tr>
<tr>
<td width="17%"> </td>
<td width="83%" colspan="2"> </td>
</tr>
<tr>
<td width="17%" valign="top">Available Courses</td>
<td width="19%">
</p>
</td>
<td width="64%">
<p align="left">Added Courses</td>
</tr>
<tr>
<td width="20%">
<select size="10" name="course" multiple>
<option selected value="COMM3604 Systems Analysis & design">COMM3604 Systems Analysis & design</option>
<option value="COMP3201 Computer Graphics">COMP3201 Computer Graphics</option>
<option value="COMP3202 Modelling and Visualisation">COMP3202 Modelling and Visualisation</option>
<option value="COMP3300 Operating Systems">COMP3300 Operating Systems</option>
<option value="COMP3400 Models of Programming & Computation">COMP3400 Models of Programming & Computation</option>
<option value="COMP3401 Compilers & Interpreters">COMP3401 Compilers & Interpreters</option>
<option value="COMP3402 Concurrent & Real-Time Systems">COMP3402 Concurrent & Real-Time Systems</option>
<option value="COMP3500 The Software Process">COMP3500 The Software Process</option>
<option value="COMP3501 Human-Computer Interaction">COMP3501 Human-Computer Interaction</option>
<option value="COMP3502 Information Security">COMP3502 Information Security</option>
<option value="COMP3503 Interaction Design">COMP3503 Interaction Design</option>
<option value="COMP3600 Reasoning about Software">COMP3600 Reasoning about Software</option>
<option value="COMP3601 Software Specification">COMP3601 Software Specification</option>
<option value="COMP3701 Principles of Artificial Intelligence">COMP3701 Principles of Artificial Intelligence</option>
<option value="COMP3804 Information Technology Project">COMP3804 Information Technology Project</option>
<option value="COMS3200 Computer Networks I">COMS3200 Computer Networks I</option>
<option value="INFS3100 Introduction of Information Science">INFS3100 Introduction of Information Science</option>
<option value="INFS3200 Advanced Database Systems">INFS3200 Advanced Database Systems</option>
<option value="INFS3202 Web Information Systems">INFS3202 Web Information Systems</option>
</select> </td>
<td width="19%" align="center">
<input type="submit" value=" Add " name="add " onClick="populateForm();">
<input type="submit" value="Drop" name="drop" onClick = "removeCourse()"></td>
<td width="64%" valign="top">
<p align="left">
<select size="4" name="addedcourse" multiple>
<option value="">
</select></td>
</tr>
<tr>
<td width="17%"> </td>
<td width="19%" align="center"> </td>
<td width="64%"> </td>
</tr>
<tr>
<td width="17%"> </td>
<td width="19%" align="center">
<p align="right"> </td>
<td width="64%"> </td>
</tr>
<tr>
<td width="17%" valign="Top"> </td>
<td width="19%" align="center">
</td>
<td width="64%">
<p align="center">
<input type="submit" value="Submit" name="submit" style="float: right"></td>
</tr>
<tr>
<td width="17%"> </td>
<td width="19%" align="center">
</td>
<td width="64%">
</td>
</tr>
<tr>
<td width="17%"> </td>
<td width="19%" align="center">
</td>
<td width="64%">
</td>
</tr>
</form>
</table>
</body>
</html>
Fritz the Blank
hi fritz_the_blank,
can help me look at this code, where go wrong? as i need to calculate the course unit, which doesnt really right the flow of it. it's correct when user drop all the courses, and unit is 0. but when user choose drop 1 by 1, the unit calculated is wrong.
thanks.
function removeCourse(){
var unit1 = document.courseform.unit.v
var arrKeep = new Array();
var intArrayIndex = 0
var objFormField = document.courseform.addedc
for(i=0;i<objFormField.len
{
//calculate the total unit no of added courses
if(objFormField[i].selecte
unit1 = unit1 - 4;
else
unit1 = unit1 - 2;
if(!objFormField[i].select
arrKeep[intArrayIndex] = objFormField[i].text;
intArrayIndex++;
}
}
objFormField.length=0;
for(i=0;i<arrKeep.length;i
objFormField[i] = new Option(arrKeep[i],arrKeep[
}
document.courseform.unit.v
}
Business Accounts
Answer for Membership
by: avnerPosted on 2003-04-20 at 04:18:42ID: 8362182
To deselect all options, set the selectedIndex to -1 :
ourse.opti ons.select edIndex = -1
document.courseform.addedc