Solved

Based on response in a form display additional form data and then submit responses to database

Posted on 2014-09-11
2
157 Views
Last Modified: 2014-09-12
I have a form that collects personal information and then based on one field selection (field: RequestType), additional data fields are displayed and eventually all data is sent to an MSAccess database. I do not understand how to display the additional data on the same page after the selection of the RequestType. I did have the form working when the additional request types were not needed.

Code is attached.
Request.txt
0
Comment
Question by:Malloy1446
  • 2
2 Comments
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
Comment Utility
You will want to do this client side although you could do it sever side but that would be a page refresh.  This is a more modern way.
http://jsbin.com/kolamawejive/1/edit?html,output
<!DOCTYPE html>
<html>
<head>
  <style>
    .chooseJournal,.chooseBook{display:none;}
  </style>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
  <script>
    $(function(){
  $(" input[name='ILLRequestType']").click(function(){
    var type=$(this).val();
    if(type==="Journal Article"){
       $('.chooseJournal').show();
      $('.chooseBook').hide();
       
    }
    if(type==="Book"){
       $('.chooseJournal').hide();
      $('.chooseBook').show();
       
    }
    
  })
  
})
  </script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
<form method="POST" action="Submit.asp" onsubmit="return validateForm()" name="FrontPage_Form1">


<!-------------------- PERSONAL INFORMATION -------------------->

	<p><b>First Name:&nbsp; </b>
	<input type="text" name="RequestorsFName" size="100"></p>
  
	<p><b>Last Name:&nbsp; </b>
	<input type="text" name="RequestorsLName" size="100"></p>
  
	<p><b>Email:&nbsp;</b>
	<input type="text" name="RequestorsEmail" size="75"></p>

	<p><b>Phone Number:&nbsp;</b>
	<input type="text" name="RequestorsPhone" size="75"></p>



<!------------------------------------ TYPE OF REQUEST ------------------------------------>
<!-------------------- BASED ON RESPONSE, APPROPRIATE FORM WILL DISPLAY -------------------->
  
	<p><b>Type of Request:&nbsp;</b>
	<blockquote>
		<input type="radio" name="ILLRequestType" value="Journal Article">Journal Article<br>
		<input type="radio" name="ILLRequestType" value="Book">Book<br>
		<input type="radio" name="ILLRequestType" value="Audiovisual">Audiovisual
	</blockquote>



<!------------------------------------ BOOK REQUEST ------------------------------------>
<!---- IF BOOK SELECTED, FOLLOWING DATA IS COLLECTED -------------------->
<div class="chooseBook">
	<p><b>Author/Editor:&nbsp; </b>
	<input type="text" name="ILLBookAuthor" size="100"></p>
  
	<p><b>Title:&nbsp; </b>
	<input type="text" name="ILLBookTitle" size="100"></p>
  
	<p><b>Publisher:&nbsp; </b>
	<input type="text" name="ILLBookPublisher" size="100"></p>
  </div>


<!--  JOURNAL ARTICLE REQUEST --->
  <div class="chooseJournal">
<!-- - IF JOURNAL ARTICLE IS SELECTED, FOLLOWING DATA IS COLLECTED --->

	<p><b>Journal Title:&nbsp; </b>
	<input type="text" name="ILLJournalTitle" size="100"></p>
  
	<p><b>ArticleTitle:&nbsp; </b>
	<input type="text" name="ILLJournalArticle" size="100"></p>
  
	<p><b>Publication Date:&nbsp; </b>
	<input type="text" name="ILLJournalPubDate" size="100"></p>
  </div>


<input type="hidden" name="SubmitDate" value="<%=Date()%>">
<input type="hidden" name="ChartID" value="<%=session("ChartID")%>">
<input type="submit" value="Submit Request">

</form> 


</body>
</html>

Open in new window

0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
If you want to do it server side, you would add each item in a separate form.

<form name="form1">

Main form info

</form>
<%
if request.form("somevalue")="Book" then
%> 
<form name="book">
Book Form
</form>
<%end if%>

Open in new window

0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

743 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

21 Experts available now in Live!

Get 1:1 Help Now