for(i=document.drop_list.Category.options.length-1;i>=0;i--)
>
does that. While inside the loop we can get the status of any element by checking selected event and it returns true if the element is selected. Then we can use if condition to get the status. if(document.drop_list.Category[i].selected)
So if it is selected then we have to execute two steps ( inside the above if condition ) first we will add the option to second drop down list and then remove it from first list. Here are the two steps.
addOption(document.drop_list.SubCat, document.drop_list.Category[i].value, document.drop_list.Category[i].value);
removeOption(Category,i);
function addOption_list(){
for(i=document.drop_list.Category.options.length-1;i>=0;i--) {
var Category=document.drop_list.Category;
if(document.drop_list.Category[i].selected){
addOption(document.drop_list.SubCat, document.drop_list.Category[i].value, document.drop_list.Category[i].value);
removeOption(Category,i);
}
}
}
<body onload="addOption_all_list()" ;>
<form name="drop_list" action="yourpage.php" method="post">
<input onclick="addOption_all_list()" ;="" value="Add All" type="button">
<select name="Category" multiple="multiple" size="7">
<option value="PHP">PHP</option>
<option value="ASP">ASP</option>
<option value="JavaScript">JavaScript</option>
<option value="HTML">HTML</option>
<option value="Perl">Perl</option>
<option value="MySQL">MySQL</option>
</select>
<input onclick="addOption_list()" ;="" value="Move >" type="button">
<input onclick="move_all_Option()" ;="" value="Move All >>" type="button">
<select id="SubCat" name="SubCat" multiple="multiple" size="7"></select>
<input onclick="removeAllOptions(SubCat)" ;="" value="Remove All" type="button">
</form>
sanjeev | 25-06-2010 |
nice tutorial i will try |
Davor | 31-08-2010 |
maybe this code below will be better, because value could be ID of item. so second parameter should be text not value. nice tutor btw. addOption(document.drop_list.SubCat, document.drop_list.Category[i].text, document.drop_list.Category[i].value); |
amit | 20-04-2014 |
help me... suppose some data is fetched from database using while(mysql_fetch_array(**) and i want that on click of each fetched data from database one div must be opened up ..please somebody tell me help please |
smo | 21-04-2014 |
You can collect the data and store them inside div tag for each record. Then display when user clicks on it. You can see the demo of FAQ script here.
Or you can send the record id as soon as the user clicks the div tag by using Ajax and return the record details. |
smo | 24-04-2014 |
One script is developed and is available here. How to display record details by user on click |
xxx | 30-11-2014 |
whats "yourpage.php"? |
smo | 30-11-2014 |
To this page all the form data will be submitted. You can change the name. |