By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,083 Members | 1,608 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,083 IT Pros & Developers. It's quick & easy.

Drop Down Box needs to display rest of HTML page

P: n/a
I'm trying to create a submission page for users to request PC/LAN
Access....If they select "Yes" in the field asking about if they need
Non Standard Software, I want several other HTML fields to become
visible....If they keep the dropdown box at "No" (default) then I want
to submit the form "as is", keeping the inapplicable HTML fields
hidden....I'm trying an "if statement" in ASP....Here's my code....I'm
thinking that the if statement may be in the wrong place in the
code....I would like it to display as soon as the selection is
switched to "Yes"...The if statement that I entered has been commented
for your convenience....

********Code Begins*******

<html>
<head>

<title>Comments</title>
</head>

<!-- #INCLUDE VIRTUAL="/_borders/top_nav.asp" -->

<% if mode <> "Send" then %>
<p>&nbsp;</p>

<p>This is a template page that will email to certain
parties and then also append to a file all information submitted
online</p>

<form method="POST" action="PC-Lan-Rqst.asp"
name="pclanrqstname" onSubmit="validate()">
&nbsp;<div align="left">
<table border="0" cellpadding="0" width="782">
<tr>
<td width="243">Full Name:</td>
<td width="529"><input type="text" name="name"
size="32"></td>
</tr>
<tr>
<td width="243">Title.:</td>
<td width="529"><input type="text" name="title"
size="32"></td>
</tr>
<tr>
<td width="243">Extension:</td>
<td width="529"><input type="text" name="ext"
size="20"></td>
</tr>
<tr>
<td width="243">Department:</td>
<td width="529"><input type="text" name="dept"
size="20"></td>
</tr>
<tr>
<td width="243">Location:</td>
<td width="529"><input type="text" name="loc"
size="20"></td>
</tr>
<tr>
<td width="243">Requestor's Name:</td>
<td width="529"><input type="text" name="rqstrname"
size="33"></td>
</tr>
<tr>
<td width="243">Dept Head's Name:</td>
<td width="529"><input type="text" name="depthdname"
size="33"></td>
</tr>
<tr>
<td width="243">Start Date (if new hire):</td>
<td width="529"><input type="text" name="strtdate"
size="20"></td>
</tr>
<tr>
<td width="243">Assignment Dates (if temp
employee):</td>
<td width="529"><input type="text" name="tempdates"
size="20"></td>
</tr>
<tr>
<td width="243">Standard Hardware</td>
<td><select size="1" name="stdrdhdwre">
<option selected>Personal Printer</option>
<option>Network Printer</option>
</select></td>
</tr>
<tr>
<td width="243"><u>Standard</u> Software:</td>
<td width="529">Microsoft Word * Microsoft Excel *
Microsoft
Access * Microsoft PowerPoint * GroupWise/Internet
E-Mail * SAP
* IBM Emulation * Anti Virus</td>
</tr>
<tr>
<td width="243">Non Standard Software?</td>
<td width="529"><select size="1"
name="nstandswoption">
<option selected>No</option>
<option>Yes (See Below)</option>
</select></td>
</tr>
<% 'THIS IS THE LINE THAT I HAVE ENTERED
If nstandswoption = "Yes" Then
%>
<tr>
<td width="243">Non Standard Software:</td>
<td width="529"><input type="text"
name="nstandsoftware" size="20"></td>
</tr>

<tr>
<td width="772" colspan="2">
<p align="center"><b>Department Cost Center
Information<br>
(required only if you are requesting non-standard
hardware or
software)</b></td>
</tr>
<tr>
<td width="243">:Cost Center:</td>
<td width="529"><input type="text" name="costcenter"
size="20"></td>
</tr>
<tr>
<td width="243">:G/L Number:</td>
<td width="529"><input type="text" name="glnumber"
size="20"></td>
</tr>
<tr>
<td width="772" colspan="2">
<p align="center"><b>Network Directory Access</b></td>
</tr>
<tr>
<td width="243">Dept Directory Name:</td>
<td width="529"><input type="text" name="deptdirname"
size="20"></td>
</tr>
<tr>
<td width="243">Other:</td>
<td width="529"><input type="text" name="other"
size="20"></td>
</tr>
<tr>
<td width="772" colspan="2">
<p align="center"><b>GroupWise Public Groups</b></td>
</tr>
<tr>
<td width="243">Add to (Group Name):</td>
<td width="529"><input type="text" name="addgroup"
size="20"></td>
</tr>
<tr>
<td width="243">Remove from (Group Name):</td>
<td width="529"><input type="text" name="removegroup"
size="20"></td>
</tr>
<tr>
<td width="243" valign="top">Justification for
Non-Standard
Hardware and Software:</td>
<td width="529"><textarea rows="7"
name="justification" cols="43"></textarea></td>
</tr>
<%
End if
%>
<tr>
<td width="243" valign="top">&nbsp;</td>
<td width="529">&nbsp;</td>
</tr>
<tr>
<td width="243" valign="top">&nbsp;</td>
<td width="529">
<input type="submit" value="Send Message"
name="Send"></td>
</tr>
</table>
</div>
<input type="hidden" name="mode" value="Send">
</form>
<script language="vbscript">
sub validate()
if trim(len(document.suggest.from.value)) = 0 then
msg = "Please note that you must provide your name" & vbcrlf & "if
you'd like to hear back from us for your suggestions..." & vbcrlf &
vbcrlf & "Continue to send this anonymously?"
if msgbox(msg, vbYesNo, "Please wait!") <> 1 then
window.event.returnvalue = false
document.suggest.from.focus()
exit sub
end if
end if
end sub
</script>
<% end if

if mode = "Send" and Err = 0 then
%>
<h2>&nbsp;</h2>
<p><img border="0" src="../images/success.jpg"></p>
<p>The following information has been successfully submitted</p>
<p>Name : <font color="#0000FF"> <%=name%></font><br>
Title : <font color="#0000FF"> <%=title%></font><br>
Ext.: <font color="#0000FF"> <%=ext%></font><br>
Department : <font color="#0000FF"> <%=dept%></font><br>
Location : <font color="#0000FF"> <%=loc%></font><br>
Requestor Name : <font color="#0000FF"> <%=rqstrname%></font><br>
Dept Head Name : <font color="#0000FF"> <%=depthdname%></font><br>
Start Date : <font color="#0000FF"> <%=strdate%></font><br>
Assignment Dates (Temp) : <font color="#0000FF">
<%=tempdates%></font><br>
Standard Hardware : <font color="#0000FF"> <%=stdrdhdwre%></font><br>
Non-Standard Software : <font color="#0000FF">
<%=nstandsoftware%></font><br>
Cost Center : <font color="#0000FF"> <%=costcenter%></font><br>
GL Number : <font color="#0000FF"> <%=glnumber%></font><br>
Dept Director's Name : <font color="#0000FF">
<%=deptdirname%></font><br>
Other : <font color="#0000FF"> <%=other%></font><br>
Add to Group : <font color="#0000FF"> <%=addgroup%></font><br>
Remove from Group : <font color="#0000FF"> <%=removegroup%></font><br>
Justification : <font color="#0000FF"> <%=justification%></font><br>
<%

end if
********End of Code********
Jul 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
You'll want to take a look at
http://www.gatewayorlando.com/conten...tV3_Submit.asp.

The key is to add a JavaScript function to the onChange event of the
drop-down box that changes the ACTION of the form to submit back to
itself and then to submit the form. Then in the page you'll need to
check the value of the particular form field request("reservationType")
and then add the appropriate fields if needed.

The overall HTML will look something like this

<FORM>
Name: <input>
Phone: <input>
email: <input>
request type: <select>

<%if request("dropDownList") = "trouble" then %>

PC Device Number: <input>
LAN ID: <input>

<%end if%>

</FORM>

dmiller23462 wrote:
I'm trying to create a submission page for users to request PC/LAN
Access....If they select "Yes" in the field asking about if they need
Non Standard Software, I want several other HTML fields to become
visible....If they keep the dropdown box at "No" (default) then I want
to submit the form "as is", keeping the inapplicable HTML fields
hidden....I'm trying an "if statement" in ASP....Here's my code....I'm
thinking that the if statement may be in the wrong place in the
code....I would like it to display as soon as the selection is
switched to "Yes"...The if statement that I entered has been commented
for your convenience....

********Code Begins*******

<html>
<head>

<title>Comments</title>
</head>

<!-- #INCLUDE VIRTUAL="/_borders/top_nav.asp" -->

<% if mode <> "Send" then %>
<p>&nbsp;</p>

<p>This is a template page that will email to certain
parties and then also append to a file all information submitted
online</p>

<form method="POST" action="PC-Lan-Rqst.asp"
name="pclanrqstname" onSubmit="validate()">
&nbsp;<div align="left">
<table border="0" cellpadding="0" width="782">
<tr>
<td width="243">Full Name:</td>
<td width="529"><input type="text" name="name"
size="32"></td>
</tr>
<tr>
<td width="243">Title.:</td>
<td width="529"><input type="text" name="title"
size="32"></td>
</tr>
<tr>
<td width="243">Extension:</td>
<td width="529"><input type="text" name="ext"
size="20"></td>
</tr>
<tr>
<td width="243">Department:</td>
<td width="529"><input type="text" name="dept"
size="20"></td>
</tr>
<tr>
<td width="243">Location:</td>
<td width="529"><input type="text" name="loc"
size="20"></td>
</tr>
<tr>
<td width="243">Requestor's Name:</td>
<td width="529"><input type="text" name="rqstrname"
size="33"></td>
</tr>
<tr>
<td width="243">Dept Head's Name:</td>
<td width="529"><input type="text" name="depthdname"
size="33"></td>
</tr>
<tr>
<td width="243">Start Date (if new hire):</td>
<td width="529"><input type="text" name="strtdate"
size="20"></td>
</tr>
<tr>
<td width="243">Assignment Dates (if temp
employee):</td>
<td width="529"><input type="text" name="tempdates"
size="20"></td>
</tr>
<tr>
<td width="243">Standard Hardware</td>
<td><select size="1" name="stdrdhdwre">
<option selected>Personal Printer</option>
<option>Network Printer</option>
</select></td>
</tr>
<tr>
<td width="243"><u>Standard</u> Software:</td>
<td width="529">Microsoft Word * Microsoft Excel *
Microsoft
Access * Microsoft PowerPoint * GroupWise/Internet
E-Mail * SAP
* IBM Emulation * Anti Virus</td>
</tr>
<tr>
<td width="243">Non Standard Software?</td>
<td width="529"><select size="1"
name="nstandswoption">
<option selected>No</option>
<option>Yes (See Below)</option>
</select></td>
</tr>
<% 'THIS IS THE LINE THAT I HAVE ENTERED
If nstandswoption = "Yes" Then
%>
<tr>
<td width="243">Non Standard Software:</td>
<td width="529"><input type="text"
name="nstandsoftware" size="20"></td>
</tr>

<tr>
<td width="772" colspan="2">
<p align="center"><b>Department Cost Center
Information<br>
(required only if you are requesting non-standard
hardware or
software)</b></td>
</tr>
<tr>
<td width="243">:Cost Center:</td>
<td width="529"><input type="text" name="costcenter"
size="20"></td>
</tr>
<tr>
<td width="243">:G/L Number:</td>
<td width="529"><input type="text" name="glnumber"
size="20"></td>
</tr>
<tr>
<td width="772" colspan="2">
<p align="center"><b>Network Directory Access</b></td>
</tr>
<tr>
<td width="243">Dept Directory Name:</td>
<td width="529"><input type="text" name="deptdirname"
size="20"></td>
</tr>
<tr>
<td width="243">Other:</td>
<td width="529"><input type="text" name="other"
size="20"></td>
</tr>
<tr>
<td width="772" colspan="2">
<p align="center"><b>GroupWise Public Groups</b></td>
</tr>
<tr>
<td width="243">Add to (Group Name):</td>
<td width="529"><input type="text" name="addgroup"
size="20"></td>
</tr>
<tr>
<td width="243">Remove from (Group Name):</td>
<td width="529"><input type="text" name="removegroup"
size="20"></td>
</tr>
<tr>
<td width="243" valign="top">Justification for
Non-Standard
Hardware and Software:</td>
<td width="529"><textarea rows="7"
name="justification" cols="43"></textarea></td>
</tr>
<%
End if
%>
<tr>
<td width="243" valign="top">&nbsp;</td>
<td width="529">&nbsp;</td>
</tr>
<tr>
<td width="243" valign="top">&nbsp;</td>
<td width="529">
<input type="submit" value="Send Message"
name="Send"></td>
</tr>
</table>
</div>
<input type="hidden" name="mode" value="Send">
</form>
<script language="vbscript">
sub validate()
if trim(len(document.suggest.from.value)) = 0 then
msg = "Please note that you must provide your name" & vbcrlf & "if
you'd like to hear back from us for your suggestions..." & vbcrlf &
vbcrlf & "Continue to send this anonymously?"
if msgbox(msg, vbYesNo, "Please wait!") <> 1 then
window.event.returnvalue = false
document.suggest.from.focus()
exit sub
end if
end if
end sub
</script>
<% end if

if mode = "Send" and Err = 0 then
%>
<h2>&nbsp;</h2>
<p><img border="0" src="../images/success.jpg"></p>
<p>The following information has been successfully submitted</p>
<p>Name : <font color="#0000FF"> <%=name%></font><br>
Title : <font color="#0000FF"> <%=title%></font><br>
Ext.: <font color="#0000FF"> <%=ext%></font><br>
Department : <font color="#0000FF"> <%=dept%></font><br>
Location : <font color="#0000FF"> <%=loc%></font><br>
Requestor Name : <font color="#0000FF"> <%=rqstrname%></font><br>
Dept Head Name : <font color="#0000FF"> <%=depthdname%></font><br>
Start Date : <font color="#0000FF"> <%=strdate%></font><br>
Assignment Dates (Temp) : <font color="#0000FF">
<%=tempdates%></font><br>
Standard Hardware : <font color="#0000FF"> <%=stdrdhdwre%></font><br>
Non-Standard Software : <font color="#0000FF">
<%=nstandsoftware%></font><br>
Cost Center : <font color="#0000FF"> <%=costcenter%></font><br>
GL Number : <font color="#0000FF"> <%=glnumber%></font><br>
Dept Director's Name : <font color="#0000FF">
<%=deptdirname%></font><br>
Other : <font color="#0000FF"> <%=other%></font><br>
Add to Group : <font color="#0000FF"> <%=addgroup%></font><br>
Remove from Group : <font color="#0000FF"> <%=removegroup%></font><br>
Justification : <font color="#0000FF"> <%=justification%></font><br>
<%

end if
********End of Code********


Jul 19 '05 #2

P: n/a
CJM
ASP is a server-side technology - it runs on the server, and the results are
sent to the client. Thus your solution wont work, because the IF statement
will be evealuated before the user even gets to see the page.

To do what you are asking, you can follow one of two approaches:

1) Omit the hidden fields, but when the user submits the form, you can
choose to redirect to a second page which shows the hidden fields only - if
the value of the dropdown is Yes . This is a 2-stage solution that just uses
ASP.

2) Use Javascript (which is a client-side technology); create some JScript
code that makes the hidden fields visible dependant on the result of the
dropdown.

1) appears to be a bit less sophisticated, but is the type of solution that
is guarranteed to work.

2) More sophisticated solution, but relies on Javascript - 13% of users use
a User Agent (Browser) that either doesnt cater for Javascript, or has
Javascript disabled.

If you are prepared to accept the issues with Javascript, repost your
question at microsoft.public.scripting.jscript....

Chris
"dmiller23462" <dm**********@yahoo.com> wrote in message
news:59**************************@posting.google.c om...
I'm trying to create a submission page for users to request PC/LAN
Access....If they select "Yes" in the field asking about if they need
Non Standard Software, I want several other HTML fields to become
visible....If they keep the dropdown box at "No" (default) then I want
to submit the form "as is", keeping the inapplicable HTML fields
hidden....I'm trying an "if statement" in ASP....Here's my code....I'm
thinking that the if statement may be in the wrong place in the
code....I would like it to display as soon as the selection is
switched to "Yes"...The if statement that I entered has been commented
for your convenience....

********Code Begins*******

<html>
<head>

<title>Comments</title>
</head>

<!-- #INCLUDE VIRTUAL="/_borders/top_nav.asp" -->

<% if mode <> "Send" then %>
<p>&nbsp;</p>

<p>This is a template page that will email to certain
parties and then also append to a file all information submitted
online</p>

<form method="POST" action="PC-Lan-Rqst.asp"
name="pclanrqstname" onSubmit="validate()">
&nbsp;<div align="left">
<table border="0" cellpadding="0" width="782">
<tr>
<td width="243">Full Name:</td>
<td width="529"><input type="text" name="name"
size="32"></td>
</tr>
<tr>
<td width="243">Title.:</td>
<td width="529"><input type="text" name="title"
size="32"></td>
</tr>
<tr>
<td width="243">Extension:</td>
<td width="529"><input type="text" name="ext"
size="20"></td>
</tr>
<tr>
<td width="243">Department:</td>
<td width="529"><input type="text" name="dept"
size="20"></td>
</tr>
<tr>
<td width="243">Location:</td>
<td width="529"><input type="text" name="loc"
size="20"></td>
</tr>
<tr>
<td width="243">Requestor's Name:</td>
<td width="529"><input type="text" name="rqstrname"
size="33"></td>
</tr>
<tr>
<td width="243">Dept Head's Name:</td>
<td width="529"><input type="text" name="depthdname"
size="33"></td>
</tr>
<tr>
<td width="243">Start Date (if new hire):</td>
<td width="529"><input type="text" name="strtdate"
size="20"></td>
</tr>
<tr>
<td width="243">Assignment Dates (if temp
employee):</td>
<td width="529"><input type="text" name="tempdates"
size="20"></td>
</tr>
<tr>
<td width="243">Standard Hardware</td>
<td><select size="1" name="stdrdhdwre">
<option selected>Personal Printer</option>
<option>Network Printer</option>
</select></td>
</tr>
<tr>
<td width="243"><u>Standard</u> Software:</td>
<td width="529">Microsoft Word * Microsoft Excel *
Microsoft
Access * Microsoft PowerPoint * GroupWise/Internet
E-Mail * SAP
* IBM Emulation * Anti Virus</td>
</tr>
<tr>
<td width="243">Non Standard Software?</td>
<td width="529"><select size="1"
name="nstandswoption">
<option selected>No</option>
<option>Yes (See Below)</option>
</select></td>
</tr>
<% 'THIS IS THE LINE THAT I HAVE ENTERED
If nstandswoption = "Yes" Then
%>
<tr>
<td width="243">Non Standard Software:</td>
<td width="529"><input type="text"
name="nstandsoftware" size="20"></td>
</tr>

<tr>
<td width="772" colspan="2">
<p align="center"><b>Department Cost Center
Information<br>
(required only if you are requesting non-standard
hardware or
software)</b></td>
</tr>
<tr>
<td width="243">:Cost Center:</td>
<td width="529"><input type="text" name="costcenter"
size="20"></td>
</tr>
<tr>
<td width="243">:G/L Number:</td>
<td width="529"><input type="text" name="glnumber"
size="20"></td>
</tr>
<tr>
<td width="772" colspan="2">
<p align="center"><b>Network Directory Access</b></td>
</tr>
<tr>
<td width="243">Dept Directory Name:</td>
<td width="529"><input type="text" name="deptdirname"
size="20"></td>
</tr>
<tr>
<td width="243">Other:</td>
<td width="529"><input type="text" name="other"
size="20"></td>
</tr>
<tr>
<td width="772" colspan="2">
<p align="center"><b>GroupWise Public Groups</b></td>
</tr>
<tr>
<td width="243">Add to (Group Name):</td>
<td width="529"><input type="text" name="addgroup"
size="20"></td>
</tr>
<tr>
<td width="243">Remove from (Group Name):</td>
<td width="529"><input type="text" name="removegroup"
size="20"></td>
</tr>
<tr>
<td width="243" valign="top">Justification for
Non-Standard
Hardware and Software:</td>
<td width="529"><textarea rows="7"
name="justification" cols="43"></textarea></td>
</tr>
<%
End if
%>
<tr>
<td width="243" valign="top">&nbsp;</td>
<td width="529">&nbsp;</td>
</tr>
<tr>
<td width="243" valign="top">&nbsp;</td>
<td width="529">
<input type="submit" value="Send Message"
name="Send"></td>
</tr>
</table>
</div>
<input type="hidden" name="mode" value="Send">
</form>
<script language="vbscript">
sub validate()
if trim(len(document.suggest.from.value)) = 0 then
msg = "Please note that you must provide your name" & vbcrlf & "if
you'd like to hear back from us for your suggestions..." & vbcrlf &
vbcrlf & "Continue to send this anonymously?"
if msgbox(msg, vbYesNo, "Please wait!") <> 1 then
window.event.returnvalue = false
document.suggest.from.focus()
exit sub
end if
end if
end sub
</script>
<% end if

if mode = "Send" and Err = 0 then
%>
<h2>&nbsp;</h2>
<p><img border="0" src="../images/success.jpg"></p>
<p>The following information has been successfully submitted</p>
<p>Name : <font color="#0000FF"> <%=name%></font><br>
Title : <font color="#0000FF"> <%=title%></font><br>
Ext.: <font color="#0000FF"> <%=ext%></font><br>
Department : <font color="#0000FF"> <%=dept%></font><br>
Location : <font color="#0000FF"> <%=loc%></font><br>
Requestor Name : <font color="#0000FF"> <%=rqstrname%></font><br>
Dept Head Name : <font color="#0000FF"> <%=depthdname%></font><br>
Start Date : <font color="#0000FF"> <%=strdate%></font><br>
Assignment Dates (Temp) : <font color="#0000FF">
<%=tempdates%></font><br>
Standard Hardware : <font color="#0000FF"> <%=stdrdhdwre%></font><br>
Non-Standard Software : <font color="#0000FF">
<%=nstandsoftware%></font><br>
Cost Center : <font color="#0000FF"> <%=costcenter%></font><br>
GL Number : <font color="#0000FF"> <%=glnumber%></font><br>
Dept Director's Name : <font color="#0000FF">
<%=deptdirname%></font><br>
Other : <font color="#0000FF"> <%=other%></font><br>
Add to Group : <font color="#0000FF"> <%=addgroup%></font><br>
Remove from Group : <font color="#0000FF"> <%=removegroup%></font><br>
Justification : <font color="#0000FF"> <%=justification%></font><br>
<%

end if
********End of Code********

Jul 19 '05 #3

P: n/a
I choose specifically to have the page submit back to itself, because
when I tried using JavaScript to hide/display the additional fields for
my res form, IE didn't like suddenly displaying additional <tr>'s and
<td>'s.

David H

www.gatewayorlando.com

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #4

P: n/a
"The key is to add a JavaScript function to the onChange event of the
drop-down box that changes the ACTION of the form to submit back to
itself and then to submit the form."

I agree and here's something similar (although somewhat confusing) I put
together about something similar:

ASP Design Tips - Dependent Listboxes
http://www.bullschmidt.com/devtip-de...tlistboxes.asp

Best regards,
J. Paul Schmidt, Freelance ASP Web Consultant
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.