Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Error code while editing ASP page.

Posted on 2004-10-25
31
Medium Priority
?
277 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
Comment
Question by:zamorin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 17
  • 12
  • +1
31 Comments
 
LVL 23

Expert Comment

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

Expert Comment

by:apresto
ID: 12415653
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
ID: 12430910
I'll get back to you soon. Sorry again for the delay.

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 23

Expert Comment

by:apresto
ID: 12435665
no prob
0
 
LVL 5

Author Comment

by:zamorin
ID: 12440265
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
ID: 12447349
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
ID: 12460447
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
ID: 12460633
rs.open "SELECT * From usertable where RegNo = " & usersrch, conn
0
 
LVL 2

Expert Comment

by:gbajramo
ID: 12460776
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
ID: 12460783
wrong thread, I'll link it to the right one, sorry.
0
 
LVL 5

Author Comment

by:zamorin
ID: 12460795
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
ID: 12461027
>>>>>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
ID: 12461074
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
ID: 12465467
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
ID: 12470722
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
ID: 12479662
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
ID: 12480761
put this at the top of your page:

<% on error resume next %>

try that and post back
0
 
LVL 23

Expert Comment

by:apresto
ID: 12480773
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
ID: 12480899
Where do I add in the above code?
0
 
LVL 5

Author Comment

by:zamorin
ID: 12480905
<% on error resume next %>

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

Expert Comment

by:apresto
ID: 12485607
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:
apresto earned 1000 total points
ID: 12485757
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
ID: 12485784
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
ID: 12485793
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
ID: 12530804
sorry for the delay, I'm trying it out now.
0
 
LVL 23

Expert Comment

by:apresto
ID: 12530815
not a prob
0
 
LVL 5

Author Comment

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

0
 
LVL 23

Expert Comment

by:apresto
ID: 12530939
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
ID: 12530948
is that it now, is there anything else you need done to it?
0
 
LVL 5

Author Comment

by:zamorin
ID: 12531031
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
ID: 12535894
Not a problem, anytime

we got there evenually

:o)
0

Featured Post

Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

618 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