<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> dynamically change hyperlink text and address </title>
<link href= "Css/css.css" rel= "stylesheet" type= "Text/css" >
<script type= "Text/javascript" language= "JavaScript" >
function Netbankusername ()
{
Values=form.bankname.options[form.bankname.selectedindex].value;
Texts=form.bankname.options[form.bankname.selectedindex].text;
Switch (FORM.BANKNAME.SELECTEDINDEX)
{
Case 1:
Document.links[0].href= "http://www.cmbchina.com/";
Shownetbank1.innerhtml= "http://www.cmbchina.com/(China Merchants Bank)";
Document.links[0].href=values;
Shownetbank1.innerhtml=values+ "(" +texts+ ")";
Break
Case 2:
Document.links[0].href= "Http://www.cib.com.cn/netbank/netbank.portal";
Shownetbank1.innerhtml= "http://www.cib.com.cn/netbank/netbank.portal (Industrial Bank)";
Document.links[0].href=values;
Shownetbank1.innerhtml=values+ "(" +texts+ ")";
Break
Default
alert (Form.bankname.selectedIndex);
Break
}
}
</script>
<body>
<form action= "Cardinfo_action.asp?action=insert" method= "post" name= "form" id= "form" >
<table width= "border=" 0 ">
<tr>
<td> Please select </td>
<td>
<select name= "Bankname" onchange= "Netbankusername ()" id= "Bankname" >
<option value= "" > Please select </option>
<option value= "http://www.cmbchina.com/" > China Merchants Bank </option>
<option value= "Http://www.cib.com.cn/netbank/netbank.portal" > Industrial Bank </option>
<option value= "http://www.baidu.com" > Other </option>
</select></td>
</table>
</form>
<div style= "border:1px solid #ccc; margin:1px;width:600px;height:20px;" ><a href= "#" target= "_blank" id= "Shownetbank1" name= "Shownetbank1" > No bank selected </a></div>
</body>
JavaScript switch case