标题:请教各位,网页显示时有问题!!!
只看楼主
xiaoyihu
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-9-10
 问题点数:0 回复次数:2 
请教各位,网页显示时有问题!!!
文件比较大,把网页和里面的脚本代码放在这里,请高手帮忙看一下,非常感激!!

<html>
   <head>
      <meta HTTP-EQUIV='Pragma' CONTENT='no-cache'>
      <link rel="stylesheet" href='stylemain.css' type='text/css'>
         <link rel="stylesheet" href='colors.css' type='text/css'>
            <script language="javascript" src="util.js"></script>
            <script language="javascript">

var changed = 0;

var old_MBSSID;

var SSID = new Array();
var PreAuth = new Array();
var AuthMode = new Array();
var EncrypType = new Array();
var DefaultKeyID = new Array();
var Key1Type = new Array();
var Key1Str = new Array();
var Key2Type = new Array();
var Key2Str = new Array();
var Key3Type = new Array();
var Key3Str = new Array();
var Key4Type = new Array();
var Key4Str = new Array();
var WPAPSK = new Array();
var RekeyMethod = new Array();
var RekeyInterval = new Array();
var PMKCachePeriod = new Array();
var IEEE8021X = new Array();
var RADIUS_Server = new Array();
var RADIUS_Port = new Array();
var RADIUS_Key = new Array();
var session_timeout_interval = new Array();

function checkRange(str, num, min, max)
{
    d = atoi(str,num);
    if(d > max || d < min)
        return false;
    return true;
}

function checkIpAddr(field)
{
    if(field.value == "")
        return false;

    if ( checkAllNum(field.value) == 0)
        return false;

    if( (!checkRange(field.value,1,0,255)) ||
        (!checkRange(field.value,2,0,255)) ||
        (!checkRange(field.value,3,0,255)) ||
        (!checkRange(field.value,4,1,254)) ){
        return false;
    }
   return true;
}

function atoi(str, num)
{
    i=1;
    if(num != 1 ){
        while (i != num && str.length != 0){
            if(str.charAt(0) == '.'){
                i++;
            }
            str = str.substring(1);
        }
        if(i != num )
            return -1;
    }

    for(i=0; i<str.length; i++){
        if(str.charAt(i) == '.'){
            str = str.substring(0, i);
            break;
        }
    }
    if(str.length == 0)
        return -1;
    return parseInt(str, 10);
}

function checkHex(str){
    var len = str.length;

    for (var i=0; i<str.length; i++) {
        if ((str.charAt(i) >= '0' && str.charAt(i) <= '9') ||
            (str.charAt(i) >= 'a' && str.charAt(i) <= 'f') ||
            (str.charAt(i) >= 'A' && str.charAt(i) <= 'F') ){
                continue;
        }else
            return false;
    }
    return true;
}

function checkInjection(str)
{
    var len = str.length;
    for (var i=0; i<str.length; i++) {
        if ( str.charAt(i) == ';' || str.charAt(i) == ',' ||
             str.charAt(i) == '\r' || str.charAt(i) == '\n'){
                return false;
        }else
            continue;
    }
    return true;
}

function checkAllNum(str)
{
    for (var i=0; i<str.length; i++){
        if((str.charAt(i) >= '0' && str.charAt(i) <= '9') || (str.charAt(i) == '.' ))
            continue;
        return false;
    }
    return true;
}

function style_display_on()
{
    if (window.ActiveXObject) { // IE
        return "block";
    }
    else if (window.XMLHttpRequest) { // Mozilla, Safari,...
        return "table-row";
    }
}

var http_request = false;
function makeRequest(url, content) {
    http_request = false;
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
    if (!http_request) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    http_request.onreadystatechange = alertContents;
    http_request.open('POST', url, true);
    http_request.send(content);
}

function alertContents() {
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
//            alert(http_request.responseText);
            parseAllData(http_request.responseText);

            UpdateMBSSIDList();
            LoadFields(0, 0);

//            if(<% getWPSModeASP(); %> && <% isWPSConfiguredASP(); %>){
//                alert("Info: The security settings has been assigned under active WPS functions.\nYou still could change security setting manually but the existed WPS settings would be overwritted.");
//            }

        } else {
            alert('There was a problem with the request.');
        }
    }
}

function parseAllData(str)
{
    var all_str = new Array();
    all_str = str.split("$");

    for (var i=0; i<all_str.length-1; i++) {
        var fields_str = new Array();
        fields_str = all_str[i].split("&");

        SSID[i] = fields_str[0];
        PreAuth[i] = fields_str[1];
        AuthMode[i] = fields_str[2];
        EncrypType[i] = fields_str[3];
        DefaultKeyID[i] = fields_str[4];
        Key1Type[i] = fields_str[5];
        Key1Str[i] = fields_str[6];
        Key2Type[i] = fields_str[7];
        Key2Str[i] = fields_str[8];
        Key3Type[i] = fields_str[9];
        Key3Str[i] = fields_str[10];
        Key4Type[i] = fields_str[11];
        Key4Str[i] = fields_str[12];
        WPAPSK[i] = fields_str[13];
        RekeyMethod[i] = fields_str[14];
        RekeyInterval[i] = fields_str[15];
        PMKCachePeriod[i] = fields_str[16];
        IEEE8021X[i] = fields_str[17];
        RADIUS_Server[i] = fields_str[18];
        RADIUS_Port[i] = fields_str[19];
        RADIUS_Key[i] = fields_str[20];
        session_timeout_interval[i] = fields_str[21];

        /* !!!! IMPORTANT !!!!*/
        if(IEEE8021X[i] == "1")
            AuthMode[i] = "IEEE8021X";

        if(AuthMode[i] == "OPEN" && EncrypType[i] == "NONE" && IEEE8021X[i] == "0")
            AuthMode[i] = "Disable";
    }
}

function checkData()
{
    var securitymode;
//    var ssid = Ssid.value;
    
    securitymode = security_mode.value;
    if (securitymode == "OPEN" || securitymode == "SHARED" ||securitymode == "WEPAUTO")
    {
        return check_Wep(securitymode);
    }else if (securitymode == "WPAPSK" || securitymode == "WPA2PSK" || securitymode == "WPAPSKWPA2PSK" /* || security_mode == 5 */){
        var keyvalue = passphrase.value;

        if (keyvalue.length == 0){
            alert('Please input wpapsk key!');
            return false;
        }

        if (keyvalue.length < 8){
            alert('Please input at least 8 character of wpapsk key!');
            return false;
        }
        
        if(checkInjection(passphrase.value) == false){
            alert('Invalid characters in Pass Phrase.');
            return false;
        }

        if(cipher[0].checked != true &&
           cipher[1].checked != true &&
              cipher[2].checked != true){
              alert('Please choose a WPA Algorithms.');
              return false;
        }

        if(checkAllNum(keyRenewalInterval.value) == false){
            alert('Please input a valid key renewal interval');
            return false;
        }
        if(keyRenewalInterval.value < 60){
            alert('Warning: A short key renewal interval.');
            // return false;
        }
        if(check_wpa() == false)
            return false;
    }
    //802.1x
    else if (securitymode == "IEEE8021X") // 802.1x
    {
        if( ieee8021x_wep[0].checked == false &&
            ieee8021x_wep[1].checked == false){
            alert('Please choose the 802.1x WEP option.');
            return false;
        }
        if(check_radius() == false)
            return false;
    }else if (securitymode == "WPA" || securitymode == "WPA1WPA2") //     WPA or WPA1WP2 mixed mode
    {
        if(check_wpa() == false)
            return false;
        if(check_radius() == false)
            return false;
    }else if (securitymode == "WPA2") //         WPA2
    {
        if(check_wpa() == false)
            return false;
        if( PreAuthentication[0].checked == false &&
            PreAuthentication[1].checked == false){
            alert('Please choose the Pre-Authentication options.');
            return false;
        }

        if(!PMKCachePeriod.value.length){
            alert('Please input the PMK Cache Period.');
            return false;
        }
        if(check_radius() == false)
            return false;
    }

    return true;
}

function check_wpa()
{
        if(cipher[0].checked != true &&
           cipher[1].checked != true &&
              cipher[2].checked != true){
              alert('Please choose a WPA Algorithms.');
              return false;
        }

        if(checkAllNum(keyRenewalInterval.value) == false){
            alert('Please input a valid key renewal interval');
            return false;
        }
        if(keyRenewalInterval.value < 60){
            alert('Warning: A short key renewal interval.');
            // return false;
        }
        return true;
}

function check_radius()
{
    if(!RadiusServerIP.value.length){
        alert('Please input the radius server ip address.');
        return false;        
    }
    if(!RadiusServerPort.value.length){
        alert('Please input the radius server port number.');
        return false;        
    }
    if(!RadiusServerSecret.value.length){
        alert('Please input the radius server shared secret.');
        return false;        
    }

    if(checkIpAddr(RadiusServerIP) == false){
        alert('Please input a valid radius server ip address.');
        return false;        
    }
    if( (checkRange(RadiusServerPort.value, 1, 1, 65535)==false) ||
        (checkAllNum(RadiusServerPort.value)==false)){
        alert('Please input a valid radius server port number.');
        return false;        
    }
    if(checkInjection(RadiusServerSecret.value)==false){
        alert('The shared secret contains invalid characters.');
        return false;        
    }

    if(RadiusServerSessionTimeout.value.length){
        if(checkAllNum(RadiusServerSessionTimeout.value)==false){
            alert('Please input a valid session timeout number or u may left it empty.');
            return false;    
        }    
    }

    return true;
}

function securityMode(c_f)
{
    var security_mode;


    changed = c_f;

    hideWep();


    document.getElementById("div_security_shared_mode").style.visibility = "hidden";
    document.getElementById("div_security_shared_mode").style.display = "none";
    document.getElementById("div_wpa").style.visibility = "hidden";
    document.getElementById("div_wpa").style.display = "none";
    document.getElementById("div_wpa_algorithms").style.visibility = "hidden";
    document.getElementById("div_wpa_algorithms").style.display = "none";
    document.getElementById("wpa_passphrase").style.visibility = "hidden";
    document.getElementById("wpa_passphrase").style.display = "none";
    document.getElementById("wpa_key_renewal_interval").style.visibility = "hidden";
    document.getElementById("wpa_key_renewal_interval").style.display = "none";
    document.getElementById("wpa_PMK_Cache_Period").style.visibility = "hidden";
    document.getElementById("wpa_PMK_Cache_Period").style.display = "none";
    document.getElementById("wpa_preAuthentication").style.visibility = "hidden";
    document.getElementById("wpa_preAuthentication").style.display = "none";
    cipher[0].disabled = true;
    cipher[1].disabled = true;
    cipher[2].disabled = true;
    passphrase.disabled = true;
    keyRenewalInterval.disabled = true;
    PMKCachePeriod.disabled = true;
    PreAuthentication.disabled = true;

    // 802.1x
    document.getElementById("div_radius_server").style.visibility = "hidden";
    document.getElementById("div_radius_server").style.display = "none";
    document.getElementById("div_8021x_wep").style.visibility = "hidden";
    document.getElementById("div_8021x_wep").style.display = "none";
    ieee8021x_wep.disable = true;
    RadiusServerIP.disable = true;
    RadiusServerPort.disable = true;
    RadiusServerSecret.disable = true;    
    RadiusServerSessionTimeout.disable = true;
    RadiusServerIdleTimeout.disable = true;    

    security_mode = security_mode.value;

    if (security_mode == "OPEN" || security_mode == "SHARED" ||security_mode == "WEPAUTO"){
        showWep(security_mode);
    }else if (security_mode == "WPAPSK" || security_mode == "WPA2PSK" || security_mode == "WPAPSKWPA2PSK"){
        <!-- WPA -->
        document.getElementById("div_wpa").style.visibility = "visible";
        if (window.ActiveXObject) { // IE
            document.getElementById("div_wpa").style.display = "block";
        }
        else if (window.XMLHttpRequest) { // Mozilla, Safari,...
            document.getElementById("div_wpa").style.display = "table";
        }

        document.getElementById("div_wpa_algorithms").style.visibility = "visible";
        document.getElementById("div_wpa_algorithms").style.display = style_display_on();
        cipher[0].disabled = false;
        cipher[1].disabled = false;

        // deal with TKIP-AES mixed mode
        if(security_mode == "WPAPSK" && cipher[2].checked)
            cipher[2].checked = false;
        // deal with TKIP-AES mixed mode
        if(security_mode == "WPA2PSK" || security_mode == "WPAPSKWPA2PSK")
            cipher[2].disabled = false;

        document.getElementById("wpa_passphrase").style.visibility = "visible";
        document.getElementById("wpa_passphrase").style.display = style_display_on();
        passphrase.disabled = false;

        document.getElementById("wpa_key_renewal_interval").style.visibility = "visible";
        document.getElementById("wpa_key_renewal_interval").style.display = style_display_on();
        keyRenewalInterval.disabled = false;
    }else if (security_mode == "WPA" || security_mode == "WPA2" || security_mode == "WPA1WPA2") //wpa enterprise
    {
        document.getElementById("div_wpa").style.visibility = "visible";
        if (window.ActiveXObject) { // IE
            document.getElementById("div_wpa").style.display = "block";
        }else if (window.XMLHttpRequest) { // Mozilla, Safari,...
            document.getElementById("div_wpa").style.display = "table";
        }

        document.getElementById("div_wpa_algorithms").style.visibility = "visible";
        document.getElementById("div_wpa_algorithms").style.display = style_display_on();
        cipher[0].disabled = false;
        cipher[1].disabled = false;
        document.getElementById("wpa_key_renewal_interval").style.visibility = "visible";
        document.getElementById("wpa_key_renewal_interval").style.display = style_display_on();
        keyRenewalInterval.disabled = false;
    
        <!-- 802.1x -->
        document.getElementById("div_radius_server").style.visibility = "visible";
        document.getElementById("div_radius_server").style.display = style_display_on();
        RadiusServerIP.disable = false;
        RadiusServerPort.disable = false;
        RadiusServerSecret.disable = false;    
        RadiusServerSessionTimeout.disable = false;
        RadiusServerIdleTimeout.disable = false;    

        // deal with TKIP-AES mixed mode
        if(security_mode == "WPA" && cipher[2].checked)
            cipher[2].checked = false;
        // deal with TKIP-AES mixed mode
        if(security_mode == "WPA2"){
            cipher[2].disabled = false;
            document.getElementById("wpa_preAuthentication").style.visibility = "visible";
            document.getElementById("wpa_preAuthentication").style.display = style_display_on();
            PreAuthentication.disabled = false;
            document.getElementById("wpa_PMK_Cache_Period").style.visibility = "visible";
            document.getElementById("wpa_PMK_Cache_Period").style.display = style_display_on();
            PMKCachePeriod.disabled = false;
        }

        // deal with WPA1WPA2 mixed mode
        if(security_mode == "WPA1WPA2"){
            cipher[2].disabled = false;
        }

    }else if (security_mode == "IEEE8021X"){ // 802.1X-WEP
        document.getElementById("div_8021x_wep").style.visibility = "visible";
        document.getElementById("div_8021x_wep").style.display = style_display_on();

        document.getElementById("div_radius_server").style.visibility = "visible";
        document.getElementById("div_radius_server").style.display = style_display_on();
        ieee8021x_wep.disable = false;
        RadiusServerIP.disable = false;
        RadiusServerPort.disable = false;
        RadiusServerSecret.disable = false;    
        RadiusServerSessionTimeout.disable = false;
        //RadiusServerIdleTimeout.disable = false;
    }
}


function hideWep()
{
    document.getElementById("div_wep").style.visibility = "hidden";
    document.getElementById("div_wep").style.display = "none";
/*
    wep_key_length.disabled = true;
    wep_key_entry_method.disabled = true;
    wep_key_1.disabled = true;
    wep_key_2.disabled = true;
    wep_key_3.disabled = true;
    wep_key_4.disabled = true;
    wep_default_key.disabled = true;
*/
}
function showWep(mode)
{
    <!-- WEP -->
    document.getElementById("div_wep").style.visibility = "visible";

    if (window.ActiveXObject) { // IE
        document.getElementById("div_wep").style.display = "block";
    }
    else if (window.XMLHttpRequest) { // Mozilla, Safari...
        document.getElementById("div_wep").style.display = "table";
    }

    if(mode == "SHARED"){
        document.getElementById("div_security_shared_mode").style.visibility = "visible";
        document.getElementById("div_security_shared_mode").style.display = style_display_on();
    }
    //wep_auth_type.disabled = false;
/*    wep_key_length.disabled = false;
    wep_key_entry_method.disabled = false;
    wep_key_1.disabled = false;
    wep_key_2.disabled = false;
    wep_key_3.disabled = false;
    wep_key_4.disabled = false;
    wep_default_key.disabled = false;


    if (wep_key_length.options.selectedIndex == 0) {
        <!-- KEY length 64 bits -->
        if (wep_key_entry_method.options.selectedIndex == 0) {
          <!-- HEX -->
          wep_key_1.maxLength = 10;
          wep_key_2.maxLength = 10;
          wep_key_3.maxLength = 10;
          wep_key_4.maxLength = 10;
        }
        else {
          <!-- ASCII -->
          wep_key_1.maxLength = 5;
          wep_key_2.maxLength = 5;
          wep_key_3.maxLength = 5;
          wep_key_4.maxLength = 5;
        }
    }
    else {
        <!-- KEY length 128 bits -->
        if (wep_key_entry_method.options.selectedIndex == 0) {
          <!-- HEX -->
          wep_key_1.maxLength = 26;
          wep_key_2.maxLength = 26;
          wep_key_3.maxLength = 26;
          wep_key_4.maxLength = 26;
        }
        else {
          <!-- ASCII -->
          wep_key_1.maxLength = 13;
          wep_key_2.maxLength = 13;
          wep_key_3.maxLength = 13;
          wep_key_4.maxLength = 13;
        }
    }
*/
}


function check_Wep(securitymode)
{
    var defaultid = wep_default_key.value;
    var key_input;

    if ( defaultid == 1 )
        var keyvalue = wep_key_1.value;
    else if (defaultid == 2)
        var keyvalue = wep_key_2.value;
    else if (defaultid == 3)
        var keyvalue = wep_key_3.value;
    else if (defaultid == 4)
        var keyvalue = wep_key_4.value;

    if (keyvalue.length == 0 &&  (securitymode == "SHARED" || securitymode == "OPEN")){ // shared wep  || md5
        alert('Please input wep key'+defaultid+' !');
        return false;
    }

    var keylength = wep_key_1.value.length;
    if (keylength != 0){
        if (WEP1Select.options.selectedIndex == 0){
            if(keylength != 5 && keylength != 13) {
                alert('Please input 5 or 13 characters of wep key1 !');
                return false;
            }
            if(checkInjection(wep_key_1.value)== false){
                alert('Wep key1 contains invalid characters.');
                return false;
            }
        }
        if (WEP1Select.options.selectedIndex == 1){
            if(keylength != 10 && keylength != 26) {
                alert('Please input 10 or 26 characters of wep key1 !');
                return false;
            }
            if(checkHex(wep_key_1.value) == false){
                alert('Invalid Wep key1 format!');
                return false;
            }
        }
    }

    keylength = wep_key_2.value.length;
    if (keylength != 0){
        if (WEP2Select.options.selectedIndex == 0){
            if(keylength != 5 && keylength != 13) {
                alert('Please input 5 or 13 characters of wep key2 !');
                return false;
            }
            if(checkInjection(wep_key_1.value)== false){
                alert('Wep key2 contains invalid characters.');
                return false;
            }            
        }
        if (WEP2Select.options.selectedIndex == 1){
            if(keylength != 10 && keylength != 26) {
                alert('Please input 10 or 26 characters of wep key2 !');
                return false;
            }
            if(checkHex(wep_key_2.value) == false){
                alert('Invalid Wep key2 format!');
                return false;
            }
        }
    }

    keylength = wep_key_3.value.length;
    if (keylength != 0){
        if (WEP3Select.options.selectedIndex == 0){
            if(keylength != 5 && keylength != 13) {
                alert('Please input 5 or 13 characters of wep key3 !');
                return false;
            }
            if(checkInjection(wep_key_1.value)== false){
                alert('Wep key3 contains invalid characters.');
                return false;
            }
        }
        if (WEP3Select.options.selectedIndex == 1){
            if(keylength != 10 && keylength != 26) {
                alert('Please input 10 or 26 characters of wep key3 !');
                return false;
            }
            if(checkHex(wep_key_3.value) == false){
                alert('Invalid Wep key3 format!');
                return false;
            }            
        }
    }

    keylength = wep_key_4.value.length;
    if (keylength != 0){
        if (WEP4Select.options.selectedIndex == 0){
            if(keylength != 5 && keylength != 13) {
                alert('Please input 5 or 13 characters of wep key4 !');
                return false;
            }
            if(checkInjection(wep_key_1.value)== false){
                alert('Wep key4 contains invalid characters.');
                return false;
            }            
        }
        if (WEP4Select.options.selectedIndex == 1){
            if(keylength != 10 && keylength != 26) {
                alert('Please input 10 or 26 characters of wep key4 !');
                return false;
            }

            if(checkHex(wep_key_4.value) == false){
                alert('Invalid Wep key4 format!');
                return false;
            }            
        }
    }
    return true;
}
    
function submit_apply()
{

    if (checkData() == true){
        changed = 0;

        submit();
//        opener.location.reload();
    }
}

function LoadFields(MBSSID)
{
    var result;
    // Security Policy
    sp_select = document.getElementById("security_mode");

    sp_select.options.length = 0;
    sp_select.options[sp_select.length] = new Option("Disable",    "Disable",    false, AuthMode[MBSSID] == "Disable");
    sp_select.options[sp_select.length] = new Option("OPEN",    "OPEN",        false, AuthMode[MBSSID] == "OPEN");
    sp_select.options[sp_select.length] = new Option("SHARED",    "SHARED",     false, AuthMode[MBSSID] == "SHARED");
    sp_select.options[sp_select.length] = new Option("WEPAUTO", "WEPAUTO",    false, AuthMode[MBSSID] == "WEPAUTO");
    sp_select.options[sp_select.length] = new Option("WPA",        "WPA",        false, AuthMode[MBSSID] == "WPA");
    sp_select.options[sp_select.length] = new Option("WPA-PSK", "WPAPSK",    false, AuthMode[MBSSID] == "WPAPSK");
    sp_select.options[sp_select.length] = new Option("WPA2",    "WPA2",        false, AuthMode[MBSSID] == "WPA2");
    sp_select.options[sp_select.length] = new Option("WPA2-PSK","WPA2PSK",    false, AuthMode[MBSSID] == "WPA2PSK");
    sp_select.options[sp_select.length] = new Option("WPAPSKWPA2PSK","WPAPSKWPA2PSK",    false, AuthMode[MBSSID] == "WPAPSKWPA2PSK");
    sp_select.options[sp_select.length] = new Option("WPA1WPA2","WPA1WPA2",    false, AuthMode[MBSSID] == "WPA1WPA2");

    /*
     * until now we only support 8021X WEP for MBSSID[0]
     */
    if(MBSSID == 0)
        sp_select.options[sp_select.length] = new Option("802.1X",    "IEEE8021X",false, AuthMode[MBSSID] == "IEEE8021X");

    // WEP
    document.getElementById("WEP1").value = Key1Str[MBSSID];
    document.getElementById("WEP2").value = Key2Str[MBSSID];
    document.getElementById("WEP3").value = Key3Str[MBSSID];
    document.getElementById("WEP4").value = Key4Str[MBSSID];

    document.getElementById("WEP1Select").selectedIndex = (Key1Type[MBSSID] == "0" ? 1 : 0);
    document.getElementById("WEP2Select").selectedIndex = (Key2Type[MBSSID] == "0" ? 1 : 0);
    document.getElementById("WEP3Select").selectedIndex = (Key3Type[MBSSID] == "0" ? 1 : 0);
    document.getElementById("WEP4Select").selectedIndex = (Key4Type[MBSSID] == "0" ? 1 : 0);

    document.getElementById("wep_default_key").selectedIndex = parseInt(DefaultKeyID[MBSSID]) - 1 ;

    // SHARED && NONE
    if(AuthMode[MBSSID] == "SHARED" && EncrypType[MBSSID] == "NONE")
        document.getElementById("security_shared_mode").selectedIndex = 1;
    else
        document.getElementById("security_shared_mode").selectedIndex = 0;

    // WPA
    if(EncrypType[MBSSID] == "TKIP")
        cipher[0].checked = true;
    else if(EncrypType[MBSSID] == "AES")
        cipher[1].checked = true;
    else if(EncrypType[MBSSID] == "TKIPAES")
        cipher[2].checked = true;

    document.getElementById("passphrase").value = WPAPSK[MBSSID];
    document.getElementById("keyRenewalInterval").value = RekeyInterval[MBSSID];
    document.getElementById("PMKCachePeriod").value = PMKCachePeriod[MBSSID];
    //document.getElementById("PreAuthentication").value = PreAuth[MBSSID];
    if(PreAuth[MBSSID] == "0")
        PreAuthentication[0].checked = true;
    else
        PreAuthentication[1].checked = true;

    //802.1x wep
    if(IEEE8021X[MBSSID] == "1"){
        if(EncrypType[MBSSID] == "WEP")
            ieee8021x_wep[1].checked = true;
        else
            ieee8021x_wep[0].checked = true;
    }
    
    document.getElementById("RadiusServerIP").value = RADIUS_Server[MBSSID];
    document.getElementById("RadiusServerPort").value = RADIUS_Port[MBSSID];
    document.getElementById("RadiusServerSecret").value = RADIUS_Key[MBSSID];            
    document.getElementById("RadiusServerSessionTimeout").value = session_timeout_interval[MBSSID];
    
    securityMode(0);

}
/*
 * When user select the different SSID, this function would be called.
 */
function selectMBSSIDChanged()
{
    // check if any security settings changed
    if(changed){
        ret = confirm("Are you sure to ignore changed?");
        if(!ret){
            ssidIndex.options.selectedIndex = old_MBSSID;
            return false;
        }
        else
            changed = 0;
    }

    var selected = ssidIndex.options.selectedIndex;
    // backup for user cancel action
    old_MBSSID = selected;

    // load wep/wpa/802.1x table for MBBSSID[selected]
    LoadFields(selected);

    // radio button special case
    WPAAlgorithms = EncrypType[selected];
    IEEE8021XWEP = IEEE8021X[selected];
    PreAuthentication = PreAuth[selected];

    changeSecurityPolicyTableTitle(SSID[selected]);
    return true;
}

function changeSecurityPolicyTableTitle(t)
{
    var title = document.getElementById("sp_title");
    title.innerHTML = "Security Mode -- " + "\"" + t + "\"";
}

function initAll()
{
    parseAllData("<% getSecurity(); %>");
    //makeRequest("/goform/wirelessGetSecurity", "something");
    UpdateMBSSIDList();
    LoadFields(0, 0);
}

function UpdateMBSSIDList() {
    //var ssidIndex = document.getElementById("ssidIndex");
    //ssidIndex.options.length = 0;
    ssidIndex.length = 0;
    var defaultSelected = false;
    var selected = false;

    for(var i=0; i<SSID.length; i++){
        var j = ssidIndex.options.length;
        ssidIndex.options[j] = new Option(SSID[i], i, defaultSelected, selected);
    }
    
    old_MBSSID = 0;

    changeSecurityPolicyTableTitle(SSID[0]);
}

function setChange(c){
    changed = c;
}

var WPAAlgorithms;
function onWPAAlgorithmsClick(type)
{
    if(type == 0 && WPAAlgorithms == "TKIP") return;
    if(type == 1 && WPAAlgorithms == "AES") return;
    if(type == 2 && WPAAlgorithms == "TKIPAES") return;
    setChange(1);
}

var IEEE8021XWEP;
function onIEEE8021XWEPClick(type)
{
    if(type == 0 && IEEE8021XWEP == false) return;
    if(type == 1 && IEEE8021XWEP == true) return;
    setChange(1);
}

var PreAuthentication;
function onPreAuthenticationClick(type)
{
    if(type == 0 && PreAuthentication == false) return;
    if(type == 1 && PreAuthentication == true) return;
    setChange(1);
}

function btnApply()
{
  var loc = 'wlsec.wl?';
  with ( document.forms[0] )
  {
   loc += submitSelect(ssidIndex);
   var security_mode = getSelect(security_mode);
   var i = ssidIndex.options.selectedIndex; i++;
   loc += '&AuthMode=';
   loc += security_mode;
   if ( security_mode == 'Disable' || security_mode == 'OPEN' || security_mode == 'SHARED' || security_mode == 'WEPAUTO')
   {
    var security_shared_mode = getSelect(security_shared_mode);
    loc += '&EncrypType=';
    loc += security_shared_mode;
    var wep_default_key = getSelect(wep_default_key);
    loc += '&DefaultKeyID=';
    loc += wep_default_key;
    var type, val;
    type = getSelect(WEP1Select);
    val = wep_key_1.value;
    loc += '&Key1Type=' + type;
    loc += ('&Key1Str'+‘i‘) + '=' + encodeUrl(wep_key_1.value);
    type = getSelect(WEP2Select);
    val = wep_key_2.value;
    loc += '&Key2Type=' + type;
    loc += ('&Key1Str'+‘i‘) + '=' + encodeUrl(wep_key_2.value);
    type = getSelect(WEP3Select);
    val = wep_key_3.value;
    loc += '&Key3Type=' + type;
    loc += ('&Key1Str'+‘i‘) + '=' + encodeUrl(wep_key_3.value);
    type = getSelect(WEP4Select);
    val = wep_key_4.value;
    loc += '&Key4Type=' + type;
    loc += ('&Key1Str'+‘i‘) + '=' + encodeUrl(wep_key_4.value);
   }
   else if ( security_mode.indexOf("WPA") != -1 )
   {
    if ( cipher[0].checked == true )
     {
      loc += '&EncrypType=TKIP';
     }
    else if ( cipher[1].checked == true )
    {
     loc += '&EncrypType=AES';
    }
    else if ( cipher[2].checked == true )
    {
     loc += '&EncrypType=TKIPAES';
    }
    var val;
    val = passphrase.value;
    loc += ('&WPAPSK'+‘i‘) + '=' + encodeUrl(passphrase.value);
    val = keyRenewalInterval.value;
    loc += '&RekeyInterval=' + encodeUrl(keyRenewalInterval.value);
    val = PMKCachePeriod.value;
    loc += '&PMKCachePeriod=' + encodeUrl(PMKCachePeriod.value);
    if ( PreAuthentication[0].checked == true )
    {
     loc += '&PreAuth=0';
    }
    else if ( PreAuthentication[1].checked == true )
    {
     loc += '&PreAuth=1';
    }
    val = RadiusServerIP.value;
    loc += '&RADIUS_Server=' + encodeUrl(RadiusServerIP.value);
    val = RadiusServerPort.value;
    loc += '&RADIUS_Port=' + encodeUrl(RadiusServerPort.value);
    val = RadiusServerSecret.value;
    loc += '&RADIUS_Key=' + encodeUrl(RadiusServerSecret.value);
    val = RadiusServerSessionTimeout.value;
    loc += '&session_timeout_interval=' + encodeUrl(RadiusServerSessionTimeout.value);
   }
   else if ( security_mode == '802.1X')
   {
    var val;
    if ( ieee8021x_wep[0].checked == true )
    {
     loc += '&IEEE8021X=0';
    }
    else if ( ieee8021x_wep[1].checked == true )
    {
     loc += '&IEEE8021X=1';
    }
   }     
  }
  var code = 'location="' + loc + '"';
  eval(code);
}
</script>
</head>
<body onload="initAll()">
<table><tbody><tr><td>

<form>

<!-- ---------------------  MBSSID Selection  --------------------- -->
<table border="1" cellpadding="2" cellspacing="1" width="540" bordercolor="#FFFFFF">
<tbody><tr>
  <td><b>Select SSID</b></td>
</tr>
  <tr>
    <td class="head">SSID choice:</td>
    <td>
      <select name="ssidIndex" size="1" onchange="selectMBSSIDChanged()">
            <!-- ....Javascript will update options.... -->
      </select>
    </td>
  </tr>
</tbody></table>


<table border="1" bordercolor="#FFFFFF" cellpadding="3" cellspacing="1" hspace="2" vspace="2" width="540">
  <tbody><tr>

    <td> <span id="sp_title"><b>Security Policy</b></span></td>
  </tr>
  <tr id="div_security_infra_mode" name="div_security_infra_mode">
    <td>Security Mode:</td>
    <td>
      <select name="security_mode" id="security_mode" size="1" onchange="securityMode(1)">
            <!-- ....Javascript will update options.... -->
      </select>

    </td>
  </tr>
  <tr id="div_security_shared_mode" name="div_security_shared_mode">
    <td>Encrypt Type:</td>
    <td>
      <select name="security_shared_mode" id="security_shared_mode" size="1" onchange="securityMode(1)">
        <option value=WEP>WEP</option>
        <option value=None>None</option>
      </select>

    </td>
  </tr>

</tbody></table>
<br>

<!-- WEP -->
<table id="div_wep" name="div_wep" border="1" bordercolor="#FFFFFF" cellpadding="3" cellspacing="1" hspace="2" vspace="2" width="540">
  <tbody><tr>
    <td><b>Wire Equivalence Protection (WEP)</b></td>
  </tr>

  <tr>
    <td>Default Key:</td>
    <td colspan="2">
      <select name="wep_default_key" id="wep_default_key" size="1" onchange="setChange(1)">
    <option value="1">Key 1</option>
    <option value="2">Key 2</option>
    <option value="3">Key 3</option>
    <option value="4">Key 4</option>
      </select>
    </td>
  </tr>
  
  <tr>
    <td>WEP Key 1:</td>
    <td><input name="wep_key_1" id="WEP1" maxlength="26" value="" onKeyUp="setChange(1)"></td>
    <td><select id="WEP1Select" name="WEP1Select" onchange="setChange(1)">
        <option value="1">ASCII</option>
        <option value="0">Hex</option>
        </select></td>
  </tr>

  <tr>
    <td>WEP Key 2:</td>
    <td><input name="wep_key_2" id="WEP2" maxlength="26" value="" onKeyUp="setChange(1)"></td>
    <td><select id="WEP2Select" name="WEP2Select" onchange="setChange(1)">
        <option value="1">ASCII</option>
        <option value="0">Hex</option>
        </select></td>
  </tr>
  <tr>
    <td>WEP Key 3:</td>
    <td><input name="wep_key_3" id="WEP3" maxlength="26" value="" onKeyUp="setChange(1)"></td>
    <td><select id="WEP3Select" name="WEP3Select" onchange="setChange(1)">
        <option value="1">ASCII</option>
        <option value="0">Hex</option>
        </select></td>
  </tr>
  <tr>
    <td>WEP Key 4:</td>
    <td><input name="wep_key_4" id="WEP4" maxlength="26" value="" onKeyUp="setChange(1)"></td>
    <td><select id="WEP4Select" name="WEP4Select" onchange="setChange(1)">
        <option value="1">ASCII</option>
        <option value="0">Hex</option>
        </select></td>
  </tr>

</tbody></table>
<!-- <br /> -->

<!-- WPA -->
<table id="div_wpa" name="div_wpa" border="1" bordercolor="#FFFFFF" cellpadding="3" cellspacing="1" hspace="2" vspace="2" width="540">

  <tbody><tr>
    <td><b>WPA</b></td>
  </tr>
  <tr id="div_wpa_algorithms" name="div_wpa_algorithms">
    <td>WPA Algorithms:</td>
    <td>
      <input name="cipher" id="cipher" value="0" type="radio" onClick="onWPAAlgorithmsClick(0)">TKIP ?
      <input name="cipher" id="cipher" value="1" type="radio" onClick="onWPAAlgorithmsClick(1)">AES ?
      <input name="cipher" id="cipher" value="2" type="radio" onClick="onWPAAlgorithmsClick(2)">TKIPAES ?
    </td>
  </tr>
  <tr id="wpa_passphrase" name="wpa_passphrase">
    <td>Pass Phrase:</td>
    <td>
      <input name="passphrase" id="passphrase" size="28" maxlength="64" value="" onKeyUp="setChange(1)">
    </td>
  </tr>

  <tr id="wpa_key_renewal_interval" name="wpa_key_renewal_interval">
    <td>Key Renewal Interval:</td>
    <td>
      <input name="keyRenewalInterval" id="keyRenewalInterval" size="4" maxlength="4" value="" onKeyUp="setChange(1)"> seconds
    </td>
  </tr>

  <tr id="wpa_PMK_Cache_Period" name="wpa_PMK_Cache_Period">
    <td>PMK Cache Period:</td>
    <td>
      <input name="PMKCachePeriod" id="PMKCachePeriod" size="4" maxlength="4" value="" onKeyUp="setChange(1)"> minute
    </td>
  </tr>

  <tr id="wpa_preAuthentication" name="wpa_preAuthentication">
    <td>Pre-Authentication:</td>
    <td>
      <input name="PreAuthentication" id="PreAuthentication" value="0" type="radio" onClick="onPreAuthenticationClick(0)">Disable ?
      <input name="PreAuthentication" id="PreAuthentication" value="1" type="radio" onClick="onPreAuthenticationClick(1)">Enable ?
    </td>
  </tr>
</tbody></table>


<!-- 802.1x -->
<!-- WEP  -->
<table id="div_8021x_wep" name="div_8021x_wep" border="1" bordercolor="#FFFFFF" cellpadding="3" cellspacing="1" hspace="2" vspace="2" width="540">
  <tbody>
  <tr>
    <td><b>802.1x WEP</b></td>
  </tr>
  <tr>
        <td> WEP: </td>
        <td>
          <input name="ieee8021x_wep" id="ieee8021x_wep" value="0" type="radio" onClick="onIEEE8021XWEPClick(0)">Disable ?
          <input name="ieee8021x_wep" id="ieee8021x_wep" value="1" type="radio" onClick="onIEEE8021XWEPClick(1)">Enable
        </td>
  </tr>
</tbody></table>

<br>
<table id="div_radius_server" name="div_radius_server" border="1" bordercolor="#FFFFFF" cellpadding="3" cellspacing="1" hspace="2" vspace="2" width="540">
<tbody>
   <tr>
    <td><b>Radius Server</b></td>
   </tr>
    <tr>
        <td> IP Address: </td>
        <td> <input name="RadiusServerIP" id="RadiusServerIP" size="16" maxlength="32" value="" onKeyUp="setChange(1)"> </td>
    </tr>
    <tr>
        <td> Port: </td>
        <td> <input name="RadiusServerPort" id="RadiusServerPort" size="5" maxlength="5" value="" onKeyUp="setChange(1)"> </td>
    </tr>
    <tr>
        <td> Shared Secret: </td>
        <td> <input name="RadiusServerSecret" id="RadiusServerSecret" size="16" maxlength="64" value="" onKeyUp="setChange(1)"> </td>
    </tr>
    <tr>
        <td> Session Timeout: </td>
        <td> <input name="RadiusServerSessionTimeout" id="RadiusServerSessionTimeout" size="3" maxlength="4" value="" onKeyUp="setChange(1)"> </td>
    </tr>
    <tr>
        <td> Idle Timeout: </td>
        <td> <input name="RadiusServerIdleTimeout" id="RadiusServerIdleTimeout" size="3" maxlength="4" value="" onKeyUp="setChange(1)" readonly> </td>
    </tr>

</tbody></table>


<!-- <br /> -->
<table border="0" cellpadding="2" cellspacing="1" width="540">
  <tbody><tr align="center">

    <td>
      <input style="width: 120px;" value="Apply" onclick="btnApply()" type="button"> ? ?
      <input style="width: 120px;" value="Cancel" type="reset" onClick="window.location.reload()" >
    </td>
  </tr>
</tbody></table>
</form>

</td></tr></tbody></table>
</body></html>



下面是util.js源代码:


function isHexaDigit(digit) {
   var hexVals = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
                           "A", "B", "C", "D", "E", "F", "a", "b", "c", "d", "e", "f");
   var len = hexVals.length;
   var i = 0;
   var ret = false;

   for ( i = 0; i < len; i++ )
      if ( digit == hexVals[i] ) break;

   if ( i < len )
      ret = true;

   return ret;
}

function isValidKey(val, size) {
   var ret = false;
   var len = val.length;
   var dbSize = size * 2;

   if ( len == size )
      ret = true;
   else if ( len == dbSize ) {
      for ( i = 0; i < dbSize; i++ )
         if ( isHexaDigit(val.charAt(i)) == false )
            break;
      if ( i == dbSize )
         ret = true;
   } else
      ret = false;

   return ret;
}


function isValidHexKey(val, size) {
   var ret = false;
   if (val.length == size) {
      for ( i = 0; i < val.length; i++ ) {
         if ( isHexaDigit(val.charAt(i)) == false ) {
            break;
         }
      }
      if ( i == val.length ) {
         ret = true;
      }
   }

   return ret;
}


function isNameUnsafe(compareChar) {
   var unsafeString = "\"<>%\\^[]`\+\$\,='#&@.: \t";
    
   if ( unsafeString.indexOf(compareChar) == -1 && compareChar.charCodeAt(0) > 32
        && compareChar.charCodeAt(0) < 123 )
      return false; // found no unsafe chars, return false
   else
      return true;
}   

// Check if a name valid
function isValidName(name) {
   var i = 0;    
   
   for ( i = 0; i < name.length; i++ ) {
      if ( isNameUnsafe(name.charAt(i)) == true )
         return false;
   }

   return true;
}

// same as is isNameUnsafe but allow spaces
function isCharUnsafe(compareChar) {
   var unsafeString = "\"<>%\\^[]`\+\$\,='#&@.:\t";
    
   if ( unsafeString.indexOf(compareChar) == -1 && compareChar.charCodeAt(0) >= 32
        && compareChar.charCodeAt(0) < 123 )
      return false; // found no unsafe chars, return false
   else
      return true;
}   

function isValidNameWSpace(name) {
   var i = 0;    
   
   for ( i = 0; i < name.length; i++ ) {
      if ( isCharUnsafe(name.charAt(i)) == true )
         return false;
   }

   return true;
}

function isSameSubNet(lan1Ip, lan1Mask, lan2Ip, lan2Mask) {

   var count = 0;
   
   lan1a = lan1Ip.split('.');
   lan1m = lan1Mask.split('.');
   lan2a = lan2Ip.split('.');
   lan2m = lan2Mask.split('.');

   for (i = 0; i < 4; i++) {
      l1a_n = parseInt(lan1a[i]);
      l1m_n = parseInt(lan1m[i]);
      l2a_n = parseInt(lan2a[i]);
      l2m_n = parseInt(lan2m[i]);
      if ((l1a_n & l1m_n) == (l2a_n & l2m_n))
         count++;
   }
   if (count == 4)
      return true;
   else
      return false;
}


function isValidIpAddress(address) {
   var i = 0;

   if ( address == '0.0.0.0' ||
        address == '255.255.255.255' )
      return false;

   addrParts = address.split('.');
   if ( addrParts.length != 4 ) return false;
   for (i = 0; i < 4; i++) {
      if (isNaN(addrParts[i]) || addrParts[i] =="")
         return false;
      num = parseInt(addrParts[i]);
      if ( num < 0 || num > 255 )
         return false;
   }
   return true;
}

function getLeftMostZeroBitPos(num) {
   var i = 0;
   var numArr = [128, 64, 32, 16, 8, 4, 2, 1];

   for ( i = 0; i < numArr.length; i++ )
      if ( (num & numArr[i]) == 0 )
         return i;

   return numArr.length;
}

function getRightMostOneBitPos(num) {
   var i = 0;
   var numArr = [1, 2, 4, 8, 16, 32, 64, 128];

   for ( i = 0; i < numArr.length; i++ )
      if ( ((num & numArr[i]) >> i) == 1 )
         return (numArr.length - i - 1);

   return -1;
}

function isValidSubnetMask(mask) {
   var i = 0, num = 0;
   var zeroBitPos = 0, oneBitPos = 0;
   var zeroBitExisted = false;

   if ( mask == '0.0.0.0' )
      return false;

   maskParts = mask.split('.');
   if ( maskParts.length != 4 ) return false;

   for (i = 0; i < 4; i++) {
      if ( isNaN(maskParts[i]) == true )
         return false;
      num = parseInt(maskParts[i]);
      if ( num < 0 || num > 255 )
         return false;
      if ( zeroBitExisted == true && num != 0 )
         return false;
      zeroBitPos = getLeftMostZeroBitPos(num);
      oneBitPos = getRightMostOneBitPos(num);
      if ( zeroBitPos < oneBitPos )
         return false;
      if ( zeroBitPos < 8 )
         zeroBitExisted = true;
   }

   return true;
}

function isValidPort(port) {
   var fromport = 0;
   var toport = 100;

   portrange = port.split(':');
   if ( portrange.length < 1 || portrange.length > 2 ) {
       return false;
   }
   if ( isNaN(portrange[0]) )
       return false;
   fromport = parseInt(portrange[0]);
   
   if ( portrange.length > 1 ) {
       if ( isNaN(portrange[1]) )
          return false;
       toport = parseInt(portrange[1]);
       if ( toport <= fromport )
           return false;      
   }
   
   if ( fromport < 1 || fromport > 65535 || toport < 1 || toport > 65535 )
       return false;
   
   return true;
}

function isValidNatPort(port) {
   var fromport = 0;
   var toport = 100;

   portrange = port.split('-');
   if ( portrange.length < 1 || portrange.length > 2 ) {
       return false;
   }
   if ( isNaN(portrange[0]) )
       return false;
   fromport = parseInt(portrange[0]);

   if ( portrange.length > 1 ) {
       if ( isNaN(portrange[1]) )
          return false;
       toport = parseInt(portrange[1]);
       if ( toport <= fromport )
           return false;
   }

   if ( fromport < 1 || fromport > 65535 || toport < 1 || toport > 65535 )
       return false;

   return true;
}

function isValidMacAddress(address) {
   var c = '';
   var i = 0, j = 0;

   if ( address == 'ff:ff:ff:ff:ff:ff' ) return false;

   addrParts = address.split(':');
   if ( addrParts.length != 6 ) return false;

   for (i = 0; i < 6; i++) {
      if ( addrParts[i] == '' )
         return false;
      for ( j = 0; j < addrParts[i].length; j++ ) {
         c = addrParts[i].toLowerCase().charAt(j);
         if ( (c >= '0' && c <= '9') ||
              (c >= 'a' && c <= 'f') )
            continue;
         else
            return false;
      }
   }

   return true;
}

var hexVals = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
              "A", "B", "C", "D", "E", "F");
var unsafeString = "\"<>%\\^[]`\+\$\,'#&";
// deleted these chars from the include list ";", "/", "?", ":", "@", "=", "&" and #
// so that we could analyze actual URLs

function isUnsafe(compareChar)
// this function checks to see if a char is URL unsafe.
// Returns bool result. True = unsafe, False = safe
{
   if ( unsafeString.indexOf(compareChar) == -1 && compareChar.charCodeAt(0) > 32
        && compareChar.charCodeAt(0) < 123 )
      return false; // found no unsafe chars, return false
   else
      return true;
}

function decToHex(num, radix)
// part of the hex-ifying functionality
{
   var hexString = "";
   while ( num >= radix ) {
      temp = num % radix;
      num = Math.floor(num / radix);
      hexString += hexVals[temp];
   }
   hexString += hexVals[num];
   return reversal(hexString);
}

function reversal(s)
// part of the hex-ifying functionality
{
   var len = s.length;
   var trans = "";
   for (i = 0; i < len; i++)
      trans = trans + s.substring(len-i-1, len-i);
   s = trans;
   return s;
}

function convert(val)
// this converts a given char to url hex form
{
   return  "%" + decToHex(val.charCodeAt(0), 16);
}


function encodeUrl(val)
{
   var len     = val.length;
   var i       = 0;
   var newStr  = "";
   var original = val;

   for ( i = 0; i < len; i++ ) {
      if ( val.substring(i,i+1).charCodeAt(0) < 255 ) {
         // hack to eliminate the rest of unicode from this
         if (isUnsafe(val.substring(i,i+1)) == false)
            newStr = newStr + val.substring(i,i+1);
         else
            newStr = newStr + convert(val.substring(i,i+1));
      } else {
         // woopsie! restore.
         alert ("Found a non-ISO-8859-1 character at position: " + (i+1) + ",\nPlease eliminate before continuing.");
         newStr = original;
         // short-circuit the loop and exit
         i = len;
      }
   }

   return newStr;
}

var markStrChars = "\"'";

// Checks to see if a char is used to mark begining and ending of string.
// Returns bool result. True = special, False = not special
function isMarkStrChar(compareChar)
{
   if ( markStrChars.indexOf(compareChar) == -1 )
      return false; // found no marked string chars, return false
   else
      return true;
}

// use backslash in front one of the escape codes to process
// marked string characters.
// Returns new process string
function processMarkStrChars(str) {
   var i = 0;
   var retStr = '';

   for ( i = 0; i < str.length; i++ ) {
      if ( isMarkStrChar(str.charAt(i)) == true )
         retStr += '\\';
      retStr += str.charAt(i);
   }

   return retStr;
}

// Web page manipulation functions

function showhide(element, sh)
{
    var status;
    if (sh == 1) {
        status = "block";
    }
    else {
        status = "none"
    }
   
    if (document.getElementById)
    {
        // standard
        document.getElementById(element).style.display = status;
    }
    else if (document.all)
    {
        // old IE
        document.all[element].style.display = status;
    }
    else if (document.layers)
    {
        // Netscape 4
        document.layers[element].display = status;
    }
}

// Load / submit functions

function getSelect(item)
{
    var idx;
    if (item.options.length > 0) {
        idx = item.selectedIndex;
        return item.options[idx].value;
    }
    else {
        return '';
    }
}

function setSelect(item, value)
{
    for (i=0; i<item.options.length; i++) {
        if (item.options[i].value == value) {
            item.selectedIndex = i;
            break;
        }
    }
}

function setCheck(item, value)
{
    if ( value == '1' ) {
         item.checked = true;
    } else {
         item.checked = false;
    }
}

function setDisable(item, value)
{
    if ( value == 1 || value == '1' ) {
         item.disabled = true;
    } else {
         item.disabled = false;
    }     
}

function submitText(item)
{
    return '&' + item.name + '=' + item.value;
}

function submitSelect(item)
{
    return '&' + item.name + '=' + getSelect(item);
}


function submitCheck(item)
{
    var val;
    if (item.checked == true) {
        val = 1;
    }
    else {
        val = 0;
    }
    return '&' + item.name + '=' + val;
}

 麻烦大家了,非常感谢。
搜索更多相关主题的帖子: 网页 时有 
2008-01-08 23:03
lmhllr
Rank: 8Rank: 8
等 级:贵宾
威 望:44
帖 子:1504
专家分:42
注 册:2005-5-12
得分:0 
我晕...有一千行代码吧....?!
2008-01-08 23:38
渚薰
Rank: 6Rank: 6
等 级:贵宾
威 望:22
帖 子:1132
专家分:0
注 册:2006-8-6
得分:0 
请注意提问要提到要点上,这样随便一扔代码的做法,每人会帮你

个人ajax技术专题站: " target="_blank">http://www. 我不会闲你烦,只会闲你不够烦!
2008-01-09 08:38



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-196580-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.290018 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved