Solved

Error code while editing ASP page.

Posted on 2004-10-25
269 Views
Last Modified: 2013-12-03
Following through from:
http://www.experts-exchange.com/Web/Q_21143459.html

I need an ASP page which lets users search for a Registration Number and make the search records editable when the user clicks on the record.

The code for my current edit page without the search function is as follows. The code in the above link makes the records searchable.

<!--#include file="../inc-scripts/adocn.asp"-->
<!--#include file="../inc-scripts/verifyAdmin.asp"-->

<HTML><HEAD>
<script Language="JavaScript" src="../../maicsa4/inc-scripts/inc-js/common.js"></script>
<script Language="JavaScript" src="../../maicsa4/inc-scripts/inc-js/admin_listuser_datename.js"></script>
<SCRIPT LANGUAGE="JavaScript">
<!--
pass = true ;

function IsEmptyField(strFieldName,strMessage){
var objFormField = document.forms[0].elements[strFieldName];
var strValue = objFormField.value;
strValue = strValue.split(" ").join("")
if(strValue.length<1){
     alert("The value for " + strMessage + " cannot be left blank!");
     objFormField.focus();
     pass = false;
      return pass;
}
pass = true;
      return pass;
}


function validForm(){
   if(!IsEmptyField('pUserName','User ID')){
                  pass = false;;
   }
  else if(!IsEmptyField('pName','name')){
          pass = false;
   }

else    if(!IsEmptyField('pRegNo','Registration No')){
          pass = false;
   }
else    if(!IsEmptyField('pICNo','NRIC')){
          pass = false;
   }

     else  if(!IsEmptyField('pContact','Contact')){
          pass = false;
   }
else    if(!IsEmptyField('pEmail','Email')){
          pass = false;
   }

else if   (document.forms[0].pAccessLevel.value == '')
{
         alert("Acces Is A Reqs Field.");
          document.forms[0].pAccessLevel.focus();
          pass = false;

}
else if  ( (document.forms[0].pAccessLevel.value != 0 ) && (document.forms[0].pAccessLevel.value != 1 ) )
     {
          alert("Please Enter Your Access.");
          document.forms[0].pAccessLevel.focus();
          pass = false;

     }

     if (pass)
     {
          document.forms[0].action = "../admin/functions/fnc-listuser_datename.asp"
            document.forms[0].submit();
     }

}

//-->
</SCRIPT>

<title></title>
<meta name="Microsoft Border" content="none">
</HEAD><BODY topmargin="0" leftmargin="0">
      <FORM NAME ="AdminListUser" action = "../admin/functions/fnc-listuser_datename.asp" method = "post">

<%
Sub displayUser()
      dim strSQL, rs
            strSQL = "SELECT * FROM UserTable ORDER BY Date, Name"
      SET rs = OpenRecord(myCon, strSQL)
            Call displayAllUser(rs)
  SET rs = Nothing
End Sub

Sub displayUpdateDetails()
  dim strSQL, rs
  strSQL = "SELECT * FROM usertable WHERE userId = '" & Request.QueryString("id") & "'"
      set  rs = OpenRecord(myCon, strSQL)
      IF rs.recordCount > 0 THEN
            Call DisplayUserRecord(rs)
      END IF
      set rs = nothing
End Sub

Sub DisplayUserRecord(rs)
      strUserID            = rs("UserID")
      strPassword            = rs("Password")
      strUserName            = rs("UserName")
      strName                  = rs("Name")
      strRegNo            = rs("RegNo")
      strICNo                  = rs("ICNo")
      strContact            = rs("Contact")
      strEmail            = rs("Email")
      strAccessLevel      = rs("AccessLevel")
      strDateExpiry      = rs("Date")

      if strDateExpiry <> "" OR strDateExpiry <> null then
            strYear            = Year(strDateExpiry)
            strMonth      = Month(strDateExpiry)
            strDay            = Day(strDateExpiry)
      end if %>
      <table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
         <td width="80%" valign="top"><b><font face="Tahoma" color="#000000" size="4">MAICSA
             Interactive<br>
          </font><font face="Tahoma" color="#000000" size="3">Administration
          Module</font></b>
         </td>
         <td width="20%" valign="top">
             <p align="right"><font face="Tahoma" size="2"><b>
             <a href="../../maicsa4/admin/main.asp">Home</a></b></font>
         </td>
             
     </tr>
     <tr>
         <td width="80%">
         </td>
         <td width="20%" height="10">
         </td>
             
     </tr>
    </table>      
            <TABLE border=0 cellSpacing=1 align=center width=85%>
            <TR>      
          <TD width=100 bgcolor="#C0C0C0" valign="top" style="border: 1px solid #000000; "><font face="Tahoma" size="2"><b>User
            ID&nbsp;</b></font> </TD>
                        <TD bgcolor="#C0C0C0" style="border: 1px solid #000000; "><input name=pUserName type=text size=50 value="<%=strUserName%>"></TD></TR>                        
            <TR>
                        <TD width=100 valign="top" style="border: 1px solid #000000; "><font face="Tahoma" size="2"><b>Password&nbsp;</b></font> </TD>
                        <TD style="border: 1px solid #000000; "><input name=pPassword type=text size=50 value="<%=strPassword%>"></TD></TR>
            <TR>
                        <TD width=100 bgcolor="#C0C0C0" valign="top" style="border: 1px solid #000000; "><font face="Tahoma" size="2"><b>Name&nbsp;</b></font> </TD>
                        <TD bgcolor="#C0C0C0" style="border: 1px solid #000000; "><input name=pName type=text size=50 value="<%=strName%>"></TD></TR>
            <TR>
                        <TD valign="top" style="border: 1px solid #000000; "><font face="Tahoma" size="2"><b>Registration
                  Number&nbsp;</b></font> </TD>
                        <TD style="border: 1px solid #000000; "><input name=pRegNo type=text size=50 value="<%=strRegNo%>"></TD></TR>                        
            <TR>
                        <TD bgcolor="#C0C0C0" valign="top" style="border: 1px solid #000000; "><font face="Tahoma" size="2"><b>New
                  NRIC Number&nbsp;</b></font> </TD>
                        <TD bgcolor="#C0C0C0" style="border: 1px solid #000000; "><input name=pICNo type=text size=50 value="<%=strICNo%>"></TD></TR>                        
            <TR>
                        <TD valign="top" style="border: 1px solid #000000; "><font face="Tahoma" size="2"><b>Contact Number&nbsp;</b></font> </TD>
                        <TD style="border: 1px solid #000000; "><input name=pContact type=text size=50 value="<%=strContact%>"></TD></TR>
            <TR>
                        <TD bgcolor="#C0C0C0" valign="top" style="border: 1px solid #000000; "><font face="Tahoma" size="2"><b>E-mail
                  Address&nbsp;</b></font> </TD>
                        <TD bgcolor="#C0C0C0" style="border: 1px solid #000000; "><input name=pEmail  type=text size=50 value="<%=strEmail %>"><font face="Tahoma" size="1">*:
                  Invalid e-mail address</font></TD></TR>
            <TR>
                        <TD valign="top" style="border: 1px solid #000000; "><font face="Tahoma" size="2"><b>Expiry
                  Date</b></font></TD>
                        <TD style="border: 1px solid #000000; ">&nbsp;<select size="1" name="D1"><%
                                          for a=1 to 31 %>
                    <option value=<%=a%> <% if Cint(strDay) = a then Response.Write " selected" %>><%=a%></option><%
              next %>      
                  </select><select size="1" name="D2"><%
                                          for b=1 to 12 %>
                    <option value=<%=b%> <% if Cint(strMonth) = b then Response.Write " selected" %>><%=b%></option><%
              next %>      
                  </select><select size="1" name="D3"><%
                                          for c=2003 to 2010 %>
                    <option value=<%=c%> <% if Cint(strYear) = c then Response.Write " selected" %>><%=c%></option><%
              next %>      
                    <option value=<%=9999%> <% if Cint(strYear) = 9999 then Response.Write " selected" %>>9999</option>
                  </select><br>
                  &nbsp;
                  <font face="Tahoma" size="1">Format : dd/mm/yyyy</font>
              </TD></TR>
            <TR>
                        <TD valign="top" style="border: 1px solid #000000; " bgcolor="#C0C0C0">
                <b><font face="Tahoma" size="2">Access Level</font></b></TD>
                        <TD style="border: 1px solid #000000; " bgcolor="#C0C0C0">
                <input name=pAccessLevel  type=text size=1 value="<%=strAccessLevel%>">&nbsp;
                <font face="Tahoma" size="2">(Please enter '1' for access and
                '0' for no access)</font></TD></TR>
            <TR>
                        <TD colspan="2">
                  <p align="center">
                  <input type=hidden name=pUserID value="<%=strUserID%>">
                  <INPUT TYPE="button"  value="Update" id=button1 name=button1  onClick="if (validForm()) this.form.submit()">
                  <input type=button value="Delete" id=button2 name=button2 onclick="javascript:location.href='functions/fnc-listuser_datename.asp?type=delete&ID=<%=strUserID%>'">
                                   

 </TD>
        </TR>
                                                
            
      </TABLE><%
End Sub

Sub displayAllUser(rs) %>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td width="60%" valign="top"><b><font face="Tahoma" color="#000000" size="4">MAICSA
                    Interactive<br>
      </font><font face="Tahoma" color="#000000" size="3">Administration Module</font></b>
    </td>
    <td width="40%" valign="top">
      <b><font face="Tahoma" color="#000000" size="4">&nbsp;</font></b><font face="Tahoma" size="2">&lt;<b>
      By Expiry Date, Name</b> &gt;</font></td>
    <td width="10%" valign="top">
      <p align="right"><font face="Tahoma" size="2"><b>
      <a href="../../maicsa4/admin/main.asp">Home</a></b></font></td>
  </tr>
</table>
<table width="100%">
      <TABLE border=0 cellPadding=0 cellSpacing=1 align=center width=100%>
            <TR>   <TD bgcolor="#000080" valign="bottom" width="3%" style="font-family: Arial; font-size: 8pt"><b><font color="#FFFFFF" size="1" face="Arial">No.</font></b></TD>
                        <TD bgcolor="#000080" valign="bottom" width="10%" style="font-family: Arial; font-size: 8pt"><b><font color="#FFFFFF" size="1" face="Arial">User
                  ID</font></b></TD>
                        <TD bgcolor="#000080" valign="bottom" width="10" style="font-family: Arial; font-size: 8pt"><b><font color="#FFFFFF" size="1" face="Arial">Password</font></b></TD>
                        <TD bgcolor="#000080" valign="bottom" width="20%" style="font-family: Arial; font-size: 8pt"><b><font color="#FFFFFF" size="1" face="Arial">Name</font></b></TD>
                        <TD bgcolor="#000080" valign="bottom" width="10%" style="font-family: Arial; font-size: 8pt"><b><font color="#FFFFFF" size="1" face="Arial">Registration<br>
 Number</font></b></TD>
                        <TD bgcolor="#000080" valign="bottom" width="12%" style="font-family: Arial; font-size: 8pt"><b><font color="#FFFFFF" size="1" face="Arial">New
                  NRIC Number</font></b></TD>
                        <TD bgcolor="#000080" valign="bottom" width="10%" style="font-family: Arial; font-size: 8pt"><b><font color="#FFFFFF" size="1" face="Arial">Contact<br>
                  Number</font></b></TD>
                        <td bgcolor="#000080" valign="bottom" width="20%" style="font-family: Arial; font-size: 8pt"><b><font color="#FFFFFF" size="1" face="Arial">E-mail<br>
                  Address</font></b></td>

                        <td bgcolor="#000080" valign="bottom" width="15%" style="font-family: Arial; font-size: 8pt"><b><font color="#FFFFFF" size="1" face="Arial">
                Expiry<br>
                  Date</font></b></td>

                        <td bgcolor="#000080" valign="bottom" width="5%" style="font-family: Arial; font-size: 8pt">
                <font size="1" color="#FFFFFF"><b>Access<br>
                Level</b></font></td>

                  </TR><%
                        dim strCount, bgColorArray
                        redim bgColorArray(1)  
                        bgColorArray(0) = "#FFFFFF"
                        bgColorArray(1) = "#C0C0C0"
                        strCount = 1
                        do while not rs.EOF %>
                              <TR>
                                    <TD bgcolor="<%=bgColorArray(strCount mod 2)%>" align=center width="3%" valign="top" style="font-family: Arial; font-size: 8pt"><font face="Arial" size="1"><%=strCount%>.</font> </TD>
                                    <TD bgcolor="<%=bgColorArray(strCount mod 2)%>" width="10%" valign="top" style="font-family: Arial; font-size: 8pt"><a href="listuser_datename.asp?type=edit&id=<%=rs("UserID")%>"><font face="Arial" size="1"><%=rs("UserName")%></font></a></TD>
                                    <TD bgcolor="<%=bgColorArray(strCount mod 2)%>" width="10" valign="top" style="font-family: Arial; font-size: 8pt"><font face="Arial" size="1"><%=rs("Password")%></font></TD>
                                    <TD bgcolor="<%=bgColorArray(strCount mod 2)%>" width="20%" valign="top" style="font-family: Arial; font-size: 8pt"><font face="Arial" size="1"><%=rs("Name")%></font></TD>
                                    <TD bgcolor="<%=bgColorArray(strCount mod 2)%>" width="10%" valign="top" style="font-family: Arial; font-size: 8pt"><font face="Arial" size="1"><%=rs("RegNo")%></font></TD>
                                    <TD bgcolor="<%=bgColorArray(strCount mod 2)%>" width="12%" valign="top" style="font-family: Arial; font-size: 8pt"><font face="Arial" size="1"><%=rs("ICNo")%></font></TD>
                                    <TD bgcolor="<%=bgColorArray(strCount mod 2)%>" width="10%" valign="top" style="font-family: Arial; font-size: 8pt"><font face="Arial" size="1"><%=rs("Contact")%></font></TD>
                                    <td bgcolor="<%=bgColorArray(strCount mod 2)%>" width="20%" valign="top" style="font-family: Arial; font-size: 8pt"><font face="Arial" size="1"><%=rs("Email")%></font></td>
                                    <td bgcolor="<%=bgColorArray(strCount mod 2)%>" width="15%" valign="top" style="font-family: Arial; font-size: 8pt"><font face="Arial" size="1"><%      if rs("Date") <> "" or rs("Date") <> null then
                                                                                                                                                                                                      if Year(rs("Date")) = 9999 then
                                                                                                                                                                                                            Response.Write "Infinite"      
                                                                                                                                                                                                      else      
                                                                                                                                                                                                            Response.Write getDateCompareDBDate(rs("Date"))
                                                                                                                                                                                                      end if             
                                                                                                                                                                                                end if %></font></td>
                                    <td bgcolor="<%=bgColorArray(strCount mod 2)%>" width="5%" valign="top" style="font-family: Arial; font-size: 8pt"><font face="Arial" size="1"><%=rs("AccessLevel")%></font></td>
                                    <%
                                    rs.MoveNext      
                                    strCount = strCount + 1
                        loop %>
      </TABLE><%                  
End Sub

dim myCon
SET myCon = OpenConn()

if Request.QueryString("type") = "edit" then
      Call displayUpdateDetails()
else      
      Call displayUser()
end if
SET myCon = Nothing
%>


</FORM>
</table>
</BODY>
0
Question by:zamorin
    31 Comments
     
    LVL 23

    Expert Comment

    by:apresto
    Found it, whats the error and which line?
    0
     
    LVL 23

    Expert Comment

    by:apresto
    I made a simple one of my own based around your needs, im not sure what the problem is but here is what ive done anyway.  I have a page that lets the user type in a regno, then a page that displays the results of this regno in textboxes then a pages that updates the database with changes made in the text boxes when it is submitted:

    <B>form.html</B>
    *********************************
    <HMTL>
    <BODY>
    <TABLE>
    <FORM method="post" action="editregno.asp">
    <TR>
    <TD>
    <INPUT name="regno" type"text">
    </td>
    </tr>
    <tr>
    <td>
    <INPUT type="submit" value="submit">
    </td>
    </tr>
    </form>
    </table>
    </body>
    </html>
    *********************************


    <B>editregno.asp</B>
    *********************************
    <%

    Dim strcon
    Dim strAccessdb
    Dim adocon

    strAccessDB = "duff.mdb"
    Set adoCon = Server.CreateObject("ADODB.Connection")
    strCon = "DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=opensaysme; DBQ=" & Server.MapPath(strAccessDB)
    adoCon.Open strCon

    Set rs = server.createobject("ADODB.recordset")

    Dim usersrch
    usersrch = request.form("regno")

    rs.open "SELECT * From usertable where regno ='"&usersrch&"'", adocon
    %>

    <TABLE>
    <FORM method="post" action="updatedb.asp">

    <%
    If not rs.eof Then
      rs.movefirst  
    while not rs.eof
    %>

    <tr>
    <td><input type="text" name="userid" value="<%=rs("userid")%>"></td>
    </Tr><tr>
    <td><input type="text" name="password" value="<%=rs("password")%>"></td>
    </Tr><tr>
    <td><input type="text" name="username" value="<%=rs("username")%>"></td>
    </Tr><tr>  
    <td><input type="hidden" name="hiddenval" value="<%=rs("regno")%>"></td>
    </Tr><tr>
    <td><input type="text" name="IcNo" value="<%=rs("IcNo")%>"></td>
    </Tr><tr>
    <td><input type="text" name="Contact" value="<%=rs("Contact")%>"></td>
    </Tr><tr>
    <td><input type="text" name="Email" value="<%=rs("Email")%>"></td>
    </Tr><tr>
    <td><input type="text" name="accesslevel" value="<%=rs("accesslevel")%>"></td>
    </Tr><tr>
    <td><input type="text" name="TDate" value="<%=rs("Date")%>"></td>
    </Tr>

    <%
    rs.movenext
    wend
    Else
    response.write "There are not records to edit"
    End If
    %>
    <input type="submit" value="update">
    </form>
    </table>
    *********************************


    <B>updatedb.asp</B>
    *********************************
    <%

    Dim strcon
    Dim strAccessdb
    Dim adocon

    Dim userid, password, username, icno, contact, email, accesslevel, hiddenval, date

    userid = request.form("userid")
    password = request.form("password")
    username = request.form("username")
    icno = request.form("icno")
    contact = request.form("contact")
    email = request.form("email")
    accesslevel = request.form("accesslevel")
    hiddenval = request.form("hiddenval")
    date = request.form("tdate")

    strAccessDB = "duff.mdb"
    Set adoCon = Server.CreateObject("ADODB.Connection")
    strCon = "DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=; DBQ=" & Server.MapPath(strAccessDB)
    adoCon.Open strCon

    sql = "UPDATE usertable SET userid ="&userid&", password='"&password&"', username='"&username&"', icno='"&IcNo&"', Contact = '"&contact&"', email='"&email&"', accesslevel='"&accesslevel&"', tdate='"&date&"' WHERE regno='"&hiddenval&"'"
    adocon.execute(sql)

    %>
    *********************************

    i have used the database connection i normally use but this can be changed like in the last page we made.  These are very very basic pages and do the minimum basically but they can be incorporated into your current page with the javascript i think.

    Test it out and see what you tihnk, you should have a folder with the following:

    a database called duff (as per my example)
    a file called, form.html, editregno.asp, updatedb.asp

    u wil prob want to change the db name if you do so make sure you change it in the path at the top:

    strAccessDB = "duff.mdb"

    I just wanted to know if this is what you are looking for, if it is then we can mix it up with your current page.

    The example i have made is assuming every field in the db is a text field apart from userid, if this isnt the case remove the single quopted from either side of the variables in the sql.

    0
     
    LVL 5

    Author Comment

    by:zamorin
    I'll get back to you soon. Sorry again for the delay.

    0
     
    LVL 23

    Expert Comment

    by:apresto
    no prob
    0
     
    LVL 5

    Author Comment

    by:zamorin
    I'm getting this error:

    Error Type:
    ADODB.Recordset (0x800A0BB9)
    Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
    /maicsa4/admin/editregno.asp, line 18

    Line 18 is : rs.open "SELECT * From usertable where RegNo ='"&usersrch&"'", adocon
    0
     
    LVL 23

    Expert Comment

    by:apresto
    Im real sorry but i cant remember whether you said if regno is a text or number, if it is a number change the sql with the error to this:

    "SELECT * From usertable where RegNo = " & usersrch & " ", adocon

    normally this error appears because data types do not match up.

    do you understand the concept of using variables in sql and how to code them depending on their data type?
    0
     
    LVL 5

    Author Comment

    by:zamorin
    It works when I change line 18 to: (RegNo is a number)

    rs.open "SELECT * From usertable where RegNo = " & usersrch & " ", conn
    0
     
    LVL 3

    Expert Comment

    by:cheeky-monkey
    rs.open "SELECT * From usertable where RegNo = " & usersrch, conn
    0
     
    LVL 2

    Expert Comment

    by:gbajramo
    I followed this question through a link that says Javascript Validation. I don't see from the postings here what Javascript validation is required and where? Or is the question something else?
    0
     
    LVL 5

    Author Comment

    by:zamorin
    wrong thread, I'll link it to the right one, sorry.
    0
     
    LVL 5

    Author Comment

    by:zamorin
    This is the javascript validation question link:

    http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_21189737.html
    0
     
    LVL 23

    Expert Comment

    by:apresto
    >>>>>It works when I change line 18 to: (RegNo is a number)...

    Is there anything else we need to do.
    0
     
    LVL 5

    Author Comment

    by:zamorin
    No that's it, I just need to incorporate this code to my existing page.

    I can't also edit the page as it is, the error code is as follows:

    Error Type:
    Microsoft VBScript runtime (0x800A01A8)
    Object required: ''
    /maicsa4/admin/updatedb.asp, line 27


    0
     
    LVL 23

    Expert Comment

    by:apresto
    whats line 27? what javascript were you using, was it just stuff to validate the form, make sure there weren't blank fields etc, if so then just put this in your head tag:

    <script type="text/javascript">
    function validate(theForm)
    {
      for (var i = 0, n = theForm.elements.length; i < n; i ++)
      {
        currElem = theForm.elements[i];
        if (currElem.type == "text" && currElem.value == "")
        {
          alert("Please fill in the " + currElem.id + " field");
          currElem.focus();
          return false;
        }
              if (currElem.type == "select-one" && currElem.value == "d")
        {
          alert("Please select and option in the " + currElem.id + " dropdown");
          currElem.focus();
          return false;
        }
          
        if (currElem.id == "Email" && currElem.value.indexOf("@") < 0)
        {
          alert("Please enter a valid email address");
          currElem.focus();
          return false;
        }
      }
      return true;
    }
    </script>

    And put this in your form tag:

    onsubmit="return validate(this)"

    Thats is if you just want to make sure you havent got blank fields though

    0
     
    LVL 23

    Expert Comment

    by:apresto
    in regards to your error make usre all of the variables iun the update query are correct, those that are text are represented correctly and those that are integer are aswell, i take it you know how to do this?

    sql = "UPDATE usertable SET userid ="&userid&", password='"&password&"', username='"&username&"', icno='"&IcNo&"', Contact = '"&contact&"', email='"&email&"', accesslevel='"&accesslevel&"', tdate='"&date&"' WHERE regno='"&hiddenval&"'"
    0
     
    LVL 5

    Author Comment

    by:zamorin
    I have managed to incorporate your code with my existing page and it seems to be working fine. I just linked my registration number search results with my existing page so I can edit it from there.

    Only problem is when I enter a search value that is not a number, it gives the below error: (aaaaaaa is the test data)

    Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
    [TCX][MyODBC]Unknown column 'aaaaaaa' in 'where clause'
    /maicsa4/admin/editregno.asp, line 17

    How can I get the message to display records not found, instead of giving this error?
    (just like when I enter non-existent digit characters)
    0
     
    LVL 23

    Expert Comment

    by:apresto
    put this at the top of your page:

    <% on error resume next %>

    try that and post back
    0
     
    LVL 23

    Expert Comment

    by:apresto
    i am assuming you have an ELSE clause to display the error:

    If not rs.eof Then '>>>>IF THERE IS A MATCHING RECORD THEN TYPE...

        response.write "There is a reg no"

    ELSE '>>>>>>>>>>>>>>>OTHERWISE TYPE...

        response.write "There are no reg no's matching your entry"

    End If '>>>>>>>>>>>END
    0
     
    LVL 5

    Author Comment

    by:zamorin
    Where do I add in the above code?
    0
     
    LVL 5

    Author Comment

    by:zamorin
    <% on error resume next %>

    When I just add the above line, it goes on an infinite loop.
    0
     
    LVL 23

    Expert Comment

    by:apresto
    you need to add it to the 1st r second line of your page.  

    in that case if the cause is text values you should use some form validation to make sure its only numbers in that text field.  Ill look around...
    0
     
    LVL 23

    Accepted Solution

    by:
    Found something, this only allows the user to enter numeric values in a specified text box, put the following in your head tag:


    <head>
    <script language=javascript>
    function checkValue(e) {
         var val;
         if(typeof e.which != 'undefined') {
              val = e.which;
         }
         else {
              val = e.keyCode;
         }
         //alert(e.which);
         switch (val) {
              case 0:  //navigation keys in Mozilla
              case 8:  //backspace
              case 13: //enter
              case 46: //. (period)
              case 48: //0
              case 49: //1
              case 50: //2
              case 51: //3
              case 52: //4
              case 53: //5
              case 54: //6
              case 55: //7
              case 56: //8
              case 57: //9
                   return true;
              default:
                   return false;
         }
    }

    </script>
    </head>

    And recplace your current RegNo text field with this:

    ...

    <td><input type="hidden" name="hiddenval" value="<%=rs("regno")%>" onkeypress="return checkValue(event)"></td>

    Now you cannot physically enter numbers in the field

    try it out
    0
     
    LVL 23

    Expert Comment

    by:apresto
    nope sorry wrong one, i took that from editregno.asp, i meant to replce the text field in form.html:

    so this:

    <INPUT name="regno" type"text" onkeypress="return checkValue(event)">

    becomes this:

    0
     
    LVL 23

    Expert Comment

    by:apresto
    done it again, basically the one in the last post is what it should look like, sorry just got back from work, my mind is mush!
    0
     
    LVL 5

    Author Comment

    by:zamorin
    sorry for the delay, I'm trying it out now.
    0
     
    LVL 23

    Expert Comment

    by:apresto
    not a prob
    0
     
    LVL 5

    Author Comment

    by:zamorin
    You are a fantastic help, thanks a lot, it works fine now.

    0
     
    LVL 23

    Expert Comment

    by:apresto
    not a problem, to be honest i found that script on the net and think it is great, i am actually using it myself now ;o)
    0
     
    LVL 23

    Expert Comment

    by:apresto
    is that it now, is there anything else you need done to it?
    0
     
    LVL 5

    Author Comment

    by:zamorin
    I need to put good feedback in your profile - DONE! ;-)

    That's about it, I'm sure I'll need your help next time.

    0
     
    LVL 23

    Expert Comment

    by:apresto
    Not a problem, anytime

    we got there evenually

    :o)
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: JavaScript Coding - Massive 12-Part Bundle

    Regardless of your programming skill level, you'll go from basics to advanced concepts in a vast array of JavaScript subjects including Sammy.js, Agility.js, Ember.js, Node.js, jQuery, AJAX, Extjs, AngularJS, Knockout.js, and JSON.

    Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
    Read about why website design really matters in today's demanding market.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    856 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now