JavaScript学习代码收藏

1、JavaScript插入网页下拉框内容
<script language="JavaScript">
function init_dl_servertype()
{
document.write("<option value='9'>GSM业务</option><option value='4'>193长途业务</option><option value='5'>165数据业务</option><option value='7'>17911业务</option><option value='8'>CDMA业务</option><option value='10'>PSTN业务</option><option value='15'>CDMA1X业务</option><option value='14'>软交换业务</option><option value='99'>宝视通业务</option>");
}
</script>

<select size="1" name="dl_servertype">
<script>
   init_dl_servertype();
</script>
</select>
2、去除空格
<script language="JavaScript">
function remove_blank(in_string)
{
    var out_string = in_string;
    var re_blank = / /g;
    var re_blank_cn = / /g;
    out_string = out_string.replace(re_blank,'');
    out_string = out_string.replace(re_blank_cn,'');
        
    return out_string;
}
</script>

你可能感兴趣的:(JavaScript学习代码收藏)