home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / ins.cab / nnset.inc < prev    next >
Text File  |  1997-10-12  |  5KB  |  162 lines

  1. <%
  2. quote = chr(34)
  3. L_TEXT_TEXT = "text"
  4. L_PASSWORD_TEXT = "password"
  5.  
  6. isAdmin = Session("IsAdmin")
  7.  
  8. function checkbox(fieldname, onclickproc, adminonly)
  9.     On Error Resume Next
  10.     dim val
  11.  
  12.     if mid(fieldname,1,1) = "!" then
  13.         fieldname = mid(fieldname,2) 
  14.         val = not currentobj.Get(fieldname)
  15.     else
  16.         val = currentobj.Get(fieldname)
  17.     end if
  18.  
  19.     if err <> 0 then
  20.         checkbox = "<INPUT NAME='chk"+fieldname+"' TYPE='CHECKBOX'>"
  21.         alertuser "chk"+fieldname    
  22.     else
  23.         if (not adminonly) or isAdmin then
  24.             if val then
  25.                 output = "<INPUT NAME='chk"+fieldname+"' TYPE='CHECKBOX' CHECKED"
  26.             else
  27.                 output = "<INPUT NAME='chk"+fieldname+"' TYPE='CHECKBOX' "
  28.             end if
  29.     
  30.             if onclickproc <> "" then
  31.                 checkbox = output + " ONCLICK = "+quote + onclickproc + quote+">"
  32.             else
  33.                 checkbox = output + ">"
  34.             end if
  35.         else
  36.             if val then
  37.                 checkbox = "<IMG ALIGN=middle SRC="+quote+"images/checkon.gif"+quote+">"
  38.             else
  39.                 checkbox = "<IMG ALIGN=middle SRC="+quote+"images/checkoff.gif"+quote+">"
  40.             end if
  41.         end if 
  42.     end if
  43. end function
  44.  
  45.  
  46. function writeoption(fieldname,value, adminonly)
  47.     On Error Resume Next
  48.     dim val
  49.     val = currentobj.Get(fieldname)
  50.     if err <> 0 then
  51.         writeoption = "<OPTION>"+value
  52.         alertuser fieldname            
  53.     else
  54.         if value = val then
  55.             writeoption = "<OPTION SELECTED>"+value
  56.         else
  57.             if (isadmin or not adminonly) then            
  58.                 writeoption = "<OPTION>"+value
  59.             end if
  60.         end if
  61.     end if
  62. end function
  63.  
  64.  
  65. function radio(fieldname,value, onclickproc, adminonly)
  66.     On Error Resume Next
  67.     dim val
  68.     val = currentobj.Get(fieldname)
  69.     if err <> 0 then
  70.         radio = (printradio(fieldname, False,onclickproc,adminonly)) + ">"
  71.         alertuser "rdo"+fieldname    
  72.     else
  73.             if (typename(val)="Boolean") then
  74.                     output = printradio(fieldname, (val = value),onclickproc,adminonly)        
  75.             else
  76.                 if mid(value,1,1) = "!" then
  77.                     output = printradio(fieldname, (val <> mid(value,2)),onclickproc,adminonly)        
  78.                 else
  79.                     output = printradio(fieldname, (val = value),onclickproc,adminonly)
  80.                 end if
  81.             end if 
  82.         radio=output
  83.     end if
  84. end function
  85.  
  86. function printradio(fieldname, checked, onclickproc,adminonly)
  87.     dim output
  88.     if checked then
  89.         chkstr = "CHECKED"
  90.     else
  91.         chkstr = ""
  92.     end if 
  93.     
  94.     if ((not adminonly) or isAdmin) then
  95.         output = "<INPUT NAME="+quote+"rdo"+fieldname+quote+" TYPE="+quote+"RADIO"+quote+" "+chkstr
  96.             if onclickproc <> "" then
  97.                 printradio = output + " ONCLICK = "+quote + onclickproc + quote+">"
  98.             else
  99.                 printradio = output + ">"
  100.             end if
  101.     else
  102.         if checked then
  103.             printradio = "<IMG SRC="+quote+"images/radioon.gif"+quote+">"
  104.         else
  105.             printradio = "<IMG SRC="+quote+"images/radiooff.gif"+quote+">"
  106.         end if
  107.     end if 
  108.  
  109. end function
  110.  
  111. function text(fieldname,fieldsize,onchangeproc,onfocusproc, onblurproc,hidden,adminonly)
  112.     text = inputbox(L_TEXT_TEXT,fieldname,fieldsize,onchangeproc,onfocusproc,onblurproc,hidden,adminonly)
  113. end function
  114.  
  115. function pword(fieldname,fieldsize,onchangeproc,onfocusproc, onblurproc,hidden,adminonly)
  116.     pword = inputbox(L_PASSWORD_TEXT,fieldname,fieldsize,onchangeproc,onfocusproc,onblurproc,hidden,adminonly)
  117. end function
  118.  
  119.  
  120. function inputbox(fieldtype,fieldname,fieldsize,onchangeproc,onfocusproc, onblurproc,hidden,adminonly)
  121.     On Error Resume Next
  122.     val = currentobj.Get(fieldname)
  123.     if err <> 0 then
  124.         textstr = "<INPUT TYPE="+quote+fieldtype+quote+" NAME="+quote+fieldname+quote+ " SIZE="+size+">"
  125.         alertuser fieldname    
  126.     else
  127.         if ((not adminonly) or isAdmin) then
  128.             textstr =  "<INPUT TYPE="+quote+fieldtype+quote
  129.             textstr = textstr + " NAME="+quote+fieldname+quote
  130.             if fieldsize <> "" then
  131.                 textstr = textstr & " SIZE=" & fieldsize
  132.             else
  133.             end if
  134.             if onchangeproc <> "" then
  135.                 textstr = textstr + " OnChange="+quote + onchangeproc + quote
  136.             end if
  137.             if onfocusproc <> "" then
  138.                 textstr = textstr + " OnFocus="+quote + onfocusproc + quote
  139.             end if
  140.             if onblurproc <> "" then
  141.                 textstr = textstr + " OnBlur="+quote + onblurproc + quote
  142.             end if
  143.             textstr = textstr + " VALUE="& quote & val & quote & ">"
  144.             
  145.             if hidden then
  146.                 textstr = textstr + " <INPUT TYPE="+quote+"hidden"+quote+" NAME="+quote+"hdn"+fieldname+quote+">"
  147.             end if            
  148.         else    
  149.             textstr = "<FONT FACE=HELV SIZE=1>" & val  & "</FONT>"
  150.         end if            
  151.     end if
  152.     inputbox = textstr
  153. end function
  154.  
  155.  
  156. sub alertuser(fieldname)
  157.     rem response.write "<SCRIPT>alert("+quote+"Could not retrieve a value for "+fieldname+"."+quote+");</SCRIPT>"
  158.     response.write "<FONT COLOR=red><B>*</B></FONT>"
  159. end sub
  160.  
  161. %>
  162.