How to automatically select all option in Select

Source: Internet
Author: User
Select| selected I would like to get a JavaScript program to select all the options in the Select, and then put the program into the form of the onsubmit, so that a submission automatically selected all the options, so you can also receive, how to write this javascript?
Linux_boot---------------------------------------------------------------

<select ID=A1 multiple>
<option>123</option>
<option>456</option>
<option>789</option>
</select>
<input Type=button value=change >
---------------------------------------------------------------

Oh, no?  ... You select the selected value through the form
Submitting the past is an array ah. You don't have to choose.

If you want to handle it separately, split the array.
---------------------------------------------------------------



<form Onsubmit=ifsubmit name=frm>
.........
<select Id=select2 multiple>
<option>123</option>
<option>456</option>
<option>789</option>
</select>

</form>
<script>
function Ifsubmit () {
var objsel=frm.select;
var intlen=objsel.length;
for (Var i=0;i<intlen;i++)
Objsel[i].selected=true;
Frm.submit ();
}
</script>
---------------------------------------------------------------

<option>456</option>
<option>789</option>
</select>

</form>
<script>
function Ifsubmit () {
var objsel=frm.select;
var intlen=objsel.length;
for (Var i=0;i<intlen;i++)
Objsel[i].selected=true;

}
</script>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.