Home > Web Front-end > JS Tutorial > How to get the value in the select tag and modify it in js_javascript skills

How to get the value in the select tag and modify it in js_javascript skills

WBOY
Release: 2016-05-16 17:47:06
Original
1258 people have browsed it
The following partial code:
Copy the code The code is as follows:

< ;select name=”company_id” id=”company_id”>





Question: How about js Change BBB in the select tag to XXX, and change the value of valued in BBB to F?
The correct code is as follows:
Copy code The code is as follows:

function cheng()
{
var mylist=document.getElementById(“company_id”);
mylist.options[0].text =”XXX”;
}


Copy code The code is as follows:

//Modify the text of value="paraValue" in the select option to "paraText"
function jsUpdateItemToSelect(objSelect,objItemText,objItemValue)
{
//Judge whether it exists
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("Successfully modified");
}
else
{
alert("This item does not exist in the selection");
}
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template