0

i have a page where i have multiple rows in a table and the no of rows is not fixed.
it is fetched using php loops from the database....each row has a drop down list containing 3 values....
i want a checkbox at some part of the page...only one....
which will enable me to change the selected element of all the drop down lists at once....
pls reply fast....
its urgent....
thnks in advance :D

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by broj1
2

If you have only drop down boxes (select elements in HTML terms) in your table, you can assign this function to the checkbox's onclick event:

function selectAll {
    // read all select elements
    var selectArray = document.getElementsByTagname('select');
    // loop thorugh the select elements array
    for(var oneSelect in selectArray) {
        // if you want i.e second option be selected, use index 1
        oneSelect.selectedIndex = 1;
    }
}

You can enhance this function by checking whether checkbox is in checked state or not. If you have other select elements on the page, you can use div or class. The above code has not been tested, it is just an idea.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.