Transferring options from one multiple selection boxes to other
We can transfer options from one selection box to other by selecting one by one or at one go. The uses of such a type of selection are you can select more than one options and it offers a better picture than selecting a group of checkboxes. To get an idea how the script works, see the demo at the end of this page. You can download the page with this code also.
You can see there are four main functions the page does and each is connected to one button. All the buttons have onlick event handler connected to one function. The page on load calls one function adoption_all_list() through the body tag to populate the first drop down box with default values. There are tutorials on adding elements or options to a list box to know how the function works. There is another tutorial on removing options from the list box. You must read these two tutorials before reading this. So out of the four buttons we will discuss the button which moves the selected options from first list box to second list box. For other functions refer to those adding and removing option tutorials.
The function we will discuss is addOption_list(), it moves the selected options to the second list box. On execution of this function it collects the elements selected, to do this a for loop is used which loops through all the options of the first list box. The line
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.
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.
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);
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
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.