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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying form elements based on drop down menu

Status
Not open for further replies.

emozley

Technical User
Jan 14, 2003
769
GB
Hi,

We have a form that allows people to apply for a job. One of the questions is where did you hear about the vacancy. Currently when the user selects their choice the answer is recorded in the datbase then the page reloads. When the page reloads it looks up their answer and depending on what it finds changes the wording and also for some choices shows a <textarea> element that allows them to expand on their answer.

This is fine to an extent but ideally what I would like to do is to do it all client side which would mean the page doesn't have to reload so the whole thing will be a bit neater and it will remove some security problems.

What is the best way to go about this? Here is my code so far:

<tr>
<td colspan="2">
<span class="text2">
<strong>
<font color="navy">Where did you hear about the vacancy?</font></strong>
<font color="red">>></font>
</span>
</td>
</tr>
<tr>
<td colspan="2">
<select name="HeardViaCode" class="text2" onchange=form.submit()>
<option value="">Please Select</option>
<option value="PUB" <% If HeardViaCode="PUB" Then Response.Write("SELECTED") %>>Publication</option>
<option value="LAW" <% If HeardViaCode="LAW" Then Response.Write("SELECTED") %>>Law Fair</option>
<option value="BWB" <% If HeardViaCode="BWB" Then Response.Write("SELECTED") %>>BWB Website</option>
<option value="WRI" <% If HeardViaCode="WRI" Then Response.Write("SELECTED") %>>Enquired in writing</option>
<option value="TOT" <% If HeardViaCode="TOT" Then Response.Write("SELECTED") %>>Totally Legal Website</option>
<option value="REP" <% If HeardViaCode="REP" Then Response.Write("SELECTED") %>>Reputation/word of mouth</option>
<option value="OTH" <% If HeardViaCode="OTH" Then Response.Write("SELECTED") %>>Other</option>
</select>
</td>
</tr>
<tr>
<td colspan="2">
<span class="text2">
<%
If HeardViaCode="PUB" Then
Response.Write("Please state title(s):")
Response.Write("<br>")
End If
If HeardViaCode="LAW" Then
Response.Write("Please state which:")
Response.Write("<br>")
End If
If HeardViaCode="OTH" Then
Response.Write("Please state:")
Response.Write("<br>")
End If
%>
</td>
</tr>
<tr>
<td colspan="2">
<%
Select Case HeardViaCode
Case "PUB", "LAW", "OTH"
%>
<textarea name="HeardViaText" class="text2" cols="40" rows="5"><% = HeardViaText %></textarea>
<%
Case Else
End Select
%>
</td>
</tr>

Thanks very much

Ed
 
A have a webpage that's like a questionnaire, with multiple dependent listboxes. I used AJAX, so that a listbox's 'change' event would trigger an AJAX call to get and populate the dependent ('child') listbox, without having to refetch the whole page.

I'm using the Prototype Javascript AJAX library . This may be useful:
HTH

Max Hugen
Australia
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top