Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide a table if not all values in 1

Status
Not open for further replies.

stpmtp

MIS
Jan 6, 2006
67
US

I have a form where users enter data. Then the user can go and view the data on a different page viewdata.htm page. I was wondering if there is a way to hide the results of the form if not all the fields are filled in.
 
First up rename your page viewdata.htm to viewdata.asp. Then load the record into a recordset and if they have filled in then display the form element. Let's say you have three columns in your recordset:

<%
If rs("A")<>"" And IsNull(rs("A"))=FALSE Then
%>
<input type="text" name="A" value="<% = rs("A") %>">
<%
End If
%>

<%
If rs("B")<>"" And IsNull(rs("B"))=FALSE Then
%>
<input type="text" name="B" value="<% = rs("B") %>">
<%
End If
%>

<%
If rs("C")<>"" And IsNull(rs("C"))=FALSE Then
%>
<input type="text" name="C" value="<% = rs("C") %>">
<%
End If
%>
 
emozley,

I am sorry I think I did not explin myself well enough,

I have a form in one webpage formpage.asp then on another page the users can look at the data view.asp
 
form page

Name ID Case# Reasons
1 24 0012


view page

Name 1
ID 24
Case# 0012
Reason

so if the user does not fill all the data. hide that record
 
Code:
<%
If ((Len(Trim(Request.Form("name"))) > 0) And (Len(Trim(Request.Form("id"))) > 0) And (Len(Trim(Request.Form("case"))) > 0) And (Len(Trim(Request.Form("reason"))) > 0)) Then
%>
<table>
    <tr>
        <td>Name:</td>
        <td></td>
    </tr>
    <tr>
        <td>ID:</td>
        <td></td>
    </tr>
    <tr>
        <td>Case:</td>
        <td></td>
    </tr>
    <tr>
        <td>Reason:</td>
        <td></td>
    </tr>
</table>
<%
End If
%>

Take Care,
Mike
 
I forgot to display the actual values from the form:
Code:
<%
If ((Len(Trim(Request.Form("name"))) > 0) And (Len(Trim(Request.Form("id"))) > 0) And (Len(Trim(Request.Form("case"))) > 0) And (Len(Trim(Request.Form("reason"))) > 0)) Then
%>
<table>
    <tr>
        <td>Name:</td>
        <td><%= Trim(Request.Form("name")) %></td>
    </tr>
    <tr>
        <td>ID:</td>
        <td><%= Trim(Request.Form("name")) %></td>
    </tr>
    <tr>
        <td>Case:</td>
        <td><%= Trim(Request.Form("name")) %></td>
    </tr>
    <tr>
        <td>Reason:</td>
        <td><%= Trim(Request.Form("name")) %></td>
    </tr>
</table>
<%
End If
%>

Take Care,
Mike
 
Bah, sorry about that :| I need more coffee :)
You get the idea:
Code:
<%
If ((Len(Trim(Request.Form("name"))) > 0) And (Len(Trim(Request.Form("id"))) > 0) And (Len(Trim(Request.Form("case"))) > 0) And (Len(Trim(Request.Form("reason"))) > 0)) Then
%>
<table>
    <tr>
        <td>Name:</td>
        <td><%= Trim(Request.Form("name")) %></td>
    </tr>
    <tr>
        <td>ID:</td>
        <td><%= Trim(Request.Form("id")) %></td>
    </tr>
    <tr>
        <td>Case:</td>
        <td><%= Trim(Request.Form("case")) %></td>
    </tr>
    <tr>
        <td>Reason:</td>
        <td><%= Trim(Request.Form("reason")) %></td>
    </tr>
</table>
<%
End If
%>[/code

Take Care,
Mike
 
ohhh I see.

One more question. How would I go about if only some of the fields are filled in and then the current user or another user wants to go to the view.asp page can I put like a
<%
If rs("A")<>"" And IsNull(rs("A"))=FALSE Then
response.redirect("notfilled.asp")
else response.redirect("view.asp")
%>
 
Something like this:
Code:
<%
Dim b_completed = False

If ((Len(Trim(Request.Form("name"))) > 0) And (Len(Trim(Request.Form("id"))) > 0) And (Len(Trim(Request.Form("case"))) > 0) And (Len(Trim(Request.Form("reason"))) > 0)) Then
    b_completed = True
End If
If (b_completed) Then
%>
<table>
    <tr>
        <td>Name:</td>
        <td><%= Trim(Request.Form("name")) %></td>
    </tr>
    <tr>
        <td>ID:</td>
        <td><%= Trim(Request.Form("id")) %></td>
    </tr>
    <tr>
        <td>Case:</td>
        <td><%= Trim(Request.Form("case")) %></td>
    </tr>
    <tr>
        <td>Reason:</td>
        <td><%= Trim(Request.Form("reason")) %></td>
    </tr>
</table>
<%
Else
%>
<script>
    history.go(-1);
</script>
<%
End If
%>

This way you can send them back to the form to fill it out.

Take Care,
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top