473,405 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

show hide form

Hey

Say I have two <form> on a page like this :

<form action="private.asp" method="post" name="form1">
// code
<input type=submit value="submit" name="submit">
</form>

<form action="private2.asp" method="post" name="form2">
// code
<input type=submit value="submit" name="submit">
</form>

Is it possible to hide both on form load and then from a drop down menu
choose which of the two to show ?

Jul 20 '05 #1
3 16516
earl wrote:
<input type=submit value="submit" name="submit">
Don't name a "submit" button "submit", you're overriding the js submit
method for the form (not that you should use it anyway).
Is it possible to hide both on form load and then from a drop down menu
choose which of the two to show ?


Certainly, see below. Note however that there are some accessibility
issues to consider, for instance users deprived from javascript, or
having non-supporting agents, might not be able to navigate your website.
<style type="text/css">
#f1, #f2 {visibility:hidden}
</style>

<div id="f1">
<form action="foo">
<!-- content goes here -->
<input type="submit" value="submit 1">
</form>
</div>

<div id="f2">
<form action="foo">
<!-- content goes here -->
<input type="submit" value="submit 2">
</form>
</div>

<form action="#">
<select onchange="f(this)">
<option value="">---</option>
<option value="f1">Show form 1</option>
<option value="f2">Show form 2</option>
</select>
</form>

<script type="text/javascript">
function f(sel){
var d=document, dv;
if(d.getElementById){
for(var ii=0; ii<sel.options.length; ii++){
dv=d.getElementById(sel.options[ii].value);
if(dv)
dv.style.visibility=sel.options[ii].selected?"visible":"hidden";
}
}
}
</script>
HTH
Yep.
Jul 20 '05 #2
"Yann-Erwan Perio" <y-*******@em-lyon.com> wrote in message
news:3f***********************@news.free.fr...
earl wrote:
<input type=submit value="submit" name="submit">


Don't name a "submit" button "submit", you're overriding the js submit
method for the form (not that you should use it anyway).
Is it possible to hide both on form load and then from a drop down menu
choose which of the two to show ?


Certainly, see below. Note however that there are some accessibility
issues to consider, for instance users deprived from javascript, or
having non-supporting agents, might not be able to navigate your website.
<style type="text/css">
#f1, #f2 {visibility:hidden}
</style>

<div id="f1">
<form action="foo">
<!-- content goes here -->
<input type="submit" value="submit 1">
</form>
</div>

<div id="f2">
<form action="foo">
<!-- content goes here -->
<input type="submit" value="submit 2">
</form>
</div>

<form action="#">
<select onchange="f(this)">
<option value="">---</option>
<option value="f1">Show form 1</option>
<option value="f2">Show form 2</option>
</select>
</form>

<script type="text/javascript">
function f(sel){
var d=document, dv;
if(d.getElementById){
for(var ii=0; ii<sel.options.length; ii++){
dv=d.getElementById(sel.options[ii].value);
if(dv)
dv.style.visibility=sel.options[ii].selected?"visible":"hidden";
}
}
}
</script>
HTH
Yep.


Thanks for the reply.

One thing though, is it possible to make f1 and f2 overlap ?
Jul 20 '05 #3
earl wrote:
One thing though, is it possible to make f1 and f2 overlap ?


Sure, either position them absolutely or change the display property
instead of the visibility one. The CSS part becomes something like

<style type="text/css">
#f1, #f2 {display:none;}
form{margin:0}
</style>

and the style setting part something like

dv.style.display=sel.options[ii].selected?"block":"none";
HTH
Yep.
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: genetic.error | last post by:
I'm moving from Vb6 to VB.Net. I have a feeling this has come up before... The VS.Net MSDN file seems to state that the following should work: Form1.Show Form1.Visible = True Form1.Hide...
2
by: Ajai Kumar .R | last post by:
Hai all, I've two or more forms on my app. My requirement is, Have to show the first form asa the user press a button have to hide the first form and show the second form. If the user press the...
2
by: MOHSEN KASHANI | last post by:
Hi, I am trying to hide some form elements in a form by default and show/hide depending on which radio button is clicked. This is what I have but it is not working: <head> <style> ..noshow {...
4
by: jerryyang_la1 | last post by:
I've found this script that allows be to hide/show form elements.. <script language="JavaScript"><!-- var toggle = true; function show(object) { if (document.layers && document.layers)...
3
by: Nathan | last post by:
I read an earlier post from Gary and answered by Peter Huang concerning closing one form and showing another. I need to do the same thing in my application, but the code Peter gave didn't work for...
13
by: Tim Smallwood | last post by:
Hi, This is probably a stupid question, but I can't seem to get a form to show / load? In the older versions of VB I'd use frmMyform.show / load myForm, etc? I looked at the help file and it...
1
by: Hareth | last post by:
-------------------------------------------------------- Button1_click Dim Form2 As New Form2 Form2.Show() -------------------------------------------------------
1
by: Richard | last post by:
Hello there, I have a form that is called from a Sub Main procedure using application.run(Form1). On my main form there is a button to open an instance of Form2 and then at the same time hide...
7
by: FP | last post by:
I'm new to Java Script. I'm displaying comments people have made. Below each persons' comment I want to add 2 buttons "Reply" and "Amend". Clicking "Reply" would display an empty text field...
5
by: ali | last post by:
Hello every one i need you help regarding div hide and show. i am having a link like <a href="#" onClick="expandWin()">show/hide </a> <div id=showHide> </div> within div i have lots of...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.