?
Solved

FORM and Submit button display

Posted on 2014-11-10
6
Medium Priority
?
268 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 33

Expert Comment

by:Big Monty
ID: 40433714
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
ID: 40433784
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 33

Expert Comment

by:Big Monty
ID: 40433791
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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

Author Comment

by:Malloy1446
ID: 40433832
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 53

Expert Comment

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

padas
Topic Advisor
0
 
LVL 33

Accepted Solution

by:
Big Monty earned 2000 total points
ID: 40433846
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
Suggested Courses

762 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