How to take the value in the select tag in JS and modify the _javascript technique

Source: Internet
Author: User
Some of the code below
Copy Code code as follows:

<select name= "company_id" id= "company_id" >
<option selected= "selected" value= "B" >BBB</option>
<option value= "A" >AAA</option>
<option value= "C" >CCC</option>
</select>

problem: JS How to change the Select label in the BBB to XXX, while the valued of the BBB in the value of the change to F?
The positive solution code is as follows:
Copy Code code as follows:

Function Cheng ()
{
var Mylist=document.getelementbyid ("company_id");
mylist.options[0].text= "XXX";
}
<input type= "button" onclick= "Cheng ()" value= "change bbb to xxx"/>

Copy Code code as follows:

Modify Value= "Paravalue" in the Select option with the text "Paratext"
function Jsupdateitemtoselect (objselect,objitemtext,objitemvalue)
{
To determine whether there is
if (Jsselectisexititem (Objselect,objitemvalue))
{
for (Var i=0;i<objselect.options.length;i++)
{
if (Objselect.options[i].value = = Objitemvalue)
{
Objselect.options[i].text = Objitemtext;
Break
}
}
Alert ("Successful modification");
}
Else
{
Alert ("The item does not exist in the select");
}
}

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.