?
Solved

Show DIV when form is submitted

Posted on 2014-04-07
6
Medium Priority
?
389 Views
Last Modified: 2014-04-08
Hello,

I would like to get a DIV to come up when a user clicks the form submit button (SEARCH) on this page.  

I have tried, using this code, but it doesn't seem to work (the page works normally but no DIV pops up):

<input name="searchlocationsrentals" id="searchlocationsrentals" type="submit" class="bindexbuyrent-long" value="SEARCH NOW" align="top" onmouseover="this.style.cursor='pointer'" onclick="document.getElementById('holdpage').style.visibility='block'"/>

Open in new window


Help appreciated!  Thanks in advance.
0
Comment
Question by:Nico2011
[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
6 Comments
 
LVL 13

Expert Comment

by:duncanb7
ID: 39983718
try this
onclick="document.getElementById('holdpage').style.visibility='visible'"

http://www.w3schools.com/cssref/pr_class_visibility.asp

if still no okay, try zIndex to set the div on most top of body page

onclick="javascript:document.getElementById('holdpage').style.visibility='visible';      
document.getElementById('holdpage').style.zIndex=999;"

If still in issue, go to chrome browser options-->tools-->developer tools-console
to see and fix all javascript syntax error  and send us those error

Hope understand your question completely, if not, please pt it out

Duncan
0
 
LVL 22

Accepted Solution

by:
Kim Walker earned 2000 total points
ID: 39983735
This will not prevent the form from submitting. Do you have an onsubmit event listener on the form element to prevent this? If so, you may be looking for (display instead of visibility):
<input name="searchlocationsrentals" id="searchlocationsrentals" type="submit" 
	class="bindexbuyrent-long" value="SEARCH NOW" align="top" 
	onmouseover="this.style.cursor='pointer'" 
	onclick="document.getElementById('holdpage').style.display='block'"/>

Open in new window

0
 
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 39983742
The code works stand alone as you can see by the sample http://jsbin.com/kupugivo/1/edit?html,output

<!DOCTYPE html>
<html>
<head>
  <script>
    function showHide(divId){
    var theDiv = document.getElementById(divId);
    if(theDiv.style.display=="none"){
        theDiv.style.display="";
    }else{
        theDiv.style.display="none";
    }    
}

    </script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <div id="hidethis" style="display:none">Now you see me</div>
  <button onclick="showHide('hidethis');">Click me</button>
</body>
</html>

Open in new window


I see you have this code
<script type="text/javascript" src="deps/hideshow.js"></script>

Open in new window

and
script type="text/javascript">//<![CDATA[
			      Calendar.setup({
				  inputField : "f_date1",
		          trigger    : "f_btn1",
//		          onSelect   : function() { this.hide(); document.forms['form1'].submit() },
		          onSelect   : function() { this.hide()},				  		          //showTime   : 12,
				  min: 20140407,
				  max: 20150707,
				  fdow: 6,
		          dateFormat : "%d-%b-%Y"
			      });
				  //]]></script

Open in new window


Could one of these be interfering?   I also can see an error pop up in the console when you click the search button.
0
WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

 
LVL 13

Expert Comment

by:duncanb7
ID: 39983744
You can see the difference between display and visibility from the link

http://www.w3schools.com/css/css_display_visibility.asp

and select which one from display or visibility   css style you want

Duncan
0
 
LVL 22

Expert Comment

by:Kim Walker
ID: 39983924
Duh. I didn't notice you had a link to your page. The absence of any value in the action attribute of the form element causes the page to refresh when the submit button is activated. This would cause the element with ID of "holdpage" to return to its default display or visibility. HOWEVER, I can't find an element with ID of "holdpage". Am I missing something?
0
 

Author Closing Comment

by:Nico2011
ID: 39985402
thanks - this worked
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
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 …
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
Suggested Courses

770 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