CSDN博客

img newtower

一种新的编程思路(下):附 ntGBDP2002_Script.jsp

发表于2002/7/15 10:12:00  707人阅读

ntGBDP2002_Script.jsp

----------------------------------------------------------------------

<%--
  GBDP2002方法通用模块
  本单元没有采用javascript的数组,因为采用数组后速度非常慢
--%>

<%@page contentType="text/html;charset=GBK" %>
<%@page import="java.lang.*,java.net.*,java.sql.*,java.text.*,java.util.*" %>
<%@page import="cint.ntDB" %>
<%@page session="true" %>
<%@page errorPage="error.jsp"%>

<%
  if( hasId && !isDelete && !isAdd )
  {
%>

<script>
<%
  ntDB ntSV = new ntDB();
  ntDB ntSV1 = new ntDB(); file://numeric
  ntDB ntSV2 = new ntDB(); file://datetime
  ntDB ntSV3 = new ntDB(); file://text
  ntDB ntSV4 = new ntDB(); file://int
 
  ntSV.executeQuery(dbName,
    " select * from "+ globalTableName +" where pid = "+ id + 
    "");
  ntSV1.executeQuery(dbName,
    " select * from "+ globalTableName +"_numeric where pid = "+ id + 
    "");
  ntSV2.executeQuery(dbName,
    " select * from "+ globalTableName +"_datetime where pid = "+ id + 
    "");
  ntSV3.executeQuery(dbName,
    " select * from "+ globalTableName +"_text where pid = "+ id + 
    "");
  ntSV4.executeQuery(dbName,
    " select * from "+ globalTableName +"_int where pid = "+ id + 
    "");
 
  for(int i=0;i<ntSV.rowCount;i++)
  {
%> 
    var k_<%= i%> = "<%= ntSV.data(i,"k") %>";
    var v_<%= i%> = "<%= ntSV.ntEncodeSimple((ntSV.data(i,"v"))) %>";
<%
  } // end for
 
  for(int i=0;i<ntSV1.rowCount;i++)
  {
    String s = ntSV1.ntEncodeSimple((ntSV1.data(i,"v")));
    String s_old = s;
   
    //
    try{
      s = (new DecimalFormat("#0")).format(Double.parseDouble(s));
      if( Double.parseDouble(s) == Double.parseDouble(s_old) )
        ;
      else
        s = ""+Double.parseDouble(s_old); 
    }catch(Exception e551055){
      s = ""+Double.parseDouble(s_old); 
    }
%> 
    var k_<%= i + ntSV.rowCount %> = "<%= ntSV1.data(i,"k") %>";
    var v_<%= i + ntSV.rowCount %> = "<%= s %>";
<%
  } // end for ntSV1

  for(int i=0;i<ntSV2.rowCount;i++)
  {
    String s54 = ntSV2.ntEncodeSimple((ntSV2.data(i,"v",0,10)));
    if( ntSV2.data(i,"k").indexOf("datetime") == 0 )
      s54 = ntSV2.ntEncodeSimple((ntSV2.data(i,"v",0,19)));
%> 
    var k_<%= i + ntSV.rowCount + ntSV1.rowCount %> = "<%= ntSV2.data(i,"k") %>";
    var v_<%= i + ntSV.rowCount + ntSV1.rowCount %> = "<%= s54 %>";
<%
  } // end for
 
  for(int i=0;i<ntSV3.rowCount;i++)
  {
%> 
    var k_<%= i + ntSV.rowCount + ntSV1.rowCount + ntSV2.rowCount %> = "<%= ntSV3.data(i,"k") %>";
    var v_<%= i + ntSV.rowCount + ntSV1.rowCount + ntSV2.rowCount %> = "<%= ntSV3.ntEncodeSimple((ntSV3.data(i,"v"))) %>";
<%
  } // end for

  for(int i=0;i<ntSV4.rowCount;i++)
  {
    String s = ntSV4.ntEncodeSimple((ntSV4.data(i,"v")));
    //
    s = ""+Integer.parseInt(s);
%> 
    var k_<%= i + ntSV.rowCount + ntSV1.rowCount + ntSV2.rowCount + ntSV3.rowCount %> = "<%= ntSV4.data(i,"k") %>";
    var v_<%= i + ntSV.rowCount + ntSV1.rowCount + ntSV2.rowCount + ntSV3.rowCount %> = "<%= s %>";
<%
  } // end for ntSV4
 
%> 

  var ntLength = <%= ntSV.rowCount
                   + ntSV1.rowCount
                   + ntSV2.rowCount
                   + ntSV3.rowCount
                   + ntSV4.rowCount %>;
 
  for(var ntLoop=0;ntLoop<ntLength;ntLoop++)
  {
  file://try{
  
    eval(" var k = k_"+ ntLoop +" ; ");
    eval(" var v = v_"+ ntLoop +" ; ");
    file://确定对象
    var xName = eval("k_" + ntLoop);
    file://aaa
    var x = document.all( ''+xName );
   
    if( x == null )
    {
      x = document.all( 'numeric'+xName );
      if( x == null )
      {
        x = document.all( 'datetime'+xName );
        if( x == null )
        {
          x = document.all( 'date'+xName );
          if( x == null )
          {
            x = document.all( 'text'+xName );
            if( x == null )
            {
              x = document.all( 'int'+xName );
            } 
          }
        }
      }
    }
    if( x == null )
      continue;
   
    file://var x = document.all( eval("k_" + ntLoop) );
    file://if( x == null )
    //  continue;
     
    if( x.type == "select-one" )
    {
      for(i=0;i<x.options.length;i++)
      {
        if( x.options[i].text == v || x.options[i].value == v )
        {
          x.selectedIndex = i;
          break;
        } 
      } 
    }
   
    if( x.type == "checkbox" )
    {
        if( x.value == v )
        {
          x.checked = true;
        } 
    }

    if( x.type == "text"
        || x.type =="textarea"
        || x.type == "hidden"
        || x.type == "password"
      )
      x.value = v ; // document.all( k ).value = v ;

    if( x.length > 1 && x[0].type == "radio" )
    {
      for(i=0;i<x.length;i++)
      {
        if( x[i].value == v )
        {
          x[i].checked = true;
          break;
        } 
      } 
    }

    if( x.type == "undefined" && x.length == 1 )
    {
      file://document.all( k ).value = v ;   
      x.value = v ;   
    }

    if( x.type == "undefined" && x.length > 1 )
    {
      for(i=0;i<x.length;i++)
      {
        x[i].value = v ;   
      } 
    }
   
    file://test
    file://if( x.type == "file" )
    file://{
    //  alert("has file type");
    file://}
   
  file://}catch(e){}
 
  } // end loop

</script>

<% } // end if %>

0 0

相关博文

我的热门文章

img
取 消
img