Solved

FORM and Submit button display

Posted on 2014-11-10
6
225 Views
Last Modified: 2014-11-10
I have a form which includes a section with a function. Based on user's input (selection of an option), user is given additional fields to complete. Right now the form is working correctly. EXCEPT, the submit button is visible before the option is selected.
User first completes some personal information.
Then, based on a selection, additional fields are displayed.
I don't want to see the submit button until after the option is selected.

I am attaching the complete code.
FORM.txt
0
Comment
Question by:Malloy1446
  • 3
  • 2
6 Comments
 
LVL 32

Expert Comment

by:Big Monty
Comment Utility
first, add an ID to your submit button, so you can reference it to show/hide

<input id="btnSubmit" type="submit" value="Submit Request">

Open in new window


then, either through css or javascript, hide the button on page load. below is an example using javascript/jquery since you already have it present:

	$(function()
		{
                    $('#btnSubmit').hide();

		$(" input[name='ILLRequestType']").click(function()
                     .......

Open in new window


finally, add an event handler for the change event of the field. I'm unsure of which field you want to show/hide the button on, so as an example, I'm just going to attach it to a field called "fld":

<script>

	$(function()
		{
                $('#btnSubmit').hide();

		$(" input[name='ILLRequestType']").click(function()
		
		{
		var type=$(this).val();

			if(type==="Journal Article"){
				$('.chooseJournal').show();
				$('.chooseBook').hide();
 				$('.chooseAudiovisual').hide();
      
    		}
    		if(type==="Book"){
       			$('.chooseJournal').hide();
      			$('.chooseBook').show();
 				$('.chooseAudiovisual').hide();
    		
    		}
    		if(type==="Audiovisual"){
       			$('.chooseJournal').hide();
      			$('.chooseBook').hide();
 				$('.chooseAudiovisual').show();
    		}
    
})

              $(" input[name='fld']").change(function() {
                    //-- put in whatever your criteria is for showing the button. for example, if you want to make sure certain fields contain a value, you would do an IF statement here checking those fields

                 //-- your last line if the criteria is met would be
                 $('#btnSubmit').show();
            
                } else {    //-- criteria not met, hide button
                      $('#btnSubmit').hide();
                }
              });
  
})

</script>

Open in new window

0
 

Author Comment

by:Malloy1446
Comment Utility
I need the SUBMIT button to display AFTER the user selects the "ILLRequestType".
It would display for each "ILLRequestType"

After adding an ID to the submit button, could the .show be added to the existing function or does submit button function need it's own function code.
0
 
LVL 32

Expert Comment

by:Big Monty
Comment Utility
since that is a radio field, you should be able to show the button in the click event that you already have:

$(function()
		{
		$(" input[name='ILLRequestType']").click(function()
		
		{
		var type=$(this).val();
                $('#btnSubmit').show();

			if(type==="Journal Article"){
				$('.chooseJournal').show();
				$('.chooseBook').hide();
 				$('.chooseAudiovisual').hide();
      
    		}
    		if(type==="Book"){
       			$('.chooseJournal').hide();
      			$('.chooseBook').show();
 				$('.chooseAudiovisual').hide();
    		
    		}
    		if(type==="Audiovisual"){
       			$('.chooseJournal').hide();
      			$('.chooseBook').hide();
 				$('.chooseAudiovisual').show();
    		}
    
})
  
})

Open in new window

0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:Malloy1446
Comment Utility
I assigned an ID to the submit button and addded
            $('#btnSubmit').show();

to the IF statements function. The Submit button is still appearing before the user clicks on the option "ILLRequestType".

I am attaching the <script>
script.txt
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
Malloy1446,  I updated your question topics by adding jquery and javascript and removing sql and asp.

padas
Topic Advisor
0
 
LVL 32

Accepted Solution

by:
Big Monty earned 500 total points
Comment Utility
you need to hide the button on page load:

<script>

	$(function()
		{
                 $('#btnSubmit').hide();
		$(" input[name='ILLRequestType']").click(function()
		
		{
		var type=$(this).val();
		
			if(type==="Journal Article"){
				$('.chooseJournal').show();
				$('.chooseBook').hide();
 				$('.chooseAudiovisual').hide();
 				$('#btnSubmit').show();
      
    		}
    		if(type==="Book"){
       			$('.chooseJournal').hide();
      			$('.chooseBook').show();
 				$('.chooseAudiovisual').hide();
 				$('#btnSubmit').show();

    		}
    		if(type==="Audiovisual"){
       			$('.chooseJournal').hide();
      			$('.chooseBook').hide();
 				$('.chooseAudiovisual').show();
 				$('#btnSubmit').show();
    		}
    
})
  
})

</script>

Open in new window

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

728 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

13 Experts available now in Live!

Get 1:1 Help Now