473,503 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Show / Hide Forms

Hello,
I have a working Show / Hide form, that works on FF, but what I would
like to do is to be able to display one part when a user clicks on one
radio button and display another part when the user clicks on the
second radio button - here is the code which just shows / hides the
whole form:

<script type="text/javascript">
<!--
var dl_elements = new Array('dl_address_country',
'dl_address_region',
'dl_address_county',
'dl_address_uk_region');

function show_creation_form() {
for (i=0; i < dl_elements.length; i++) {
element_id = dl_elements[i];
element= document.getElementById(element_id);
element.style.visibility = 'visible';
}
}

function hide_creation_form() {
for (i=0; i < dl_elements.length; i++) {
element_id = dl_elements[i];
element = document.getElementById(element_id);
element.style.visibility = 'hidden';
}
}
-->
</script>

<!-- This form is for the UK only -->
<dl id="dl_address_uk_region">
<dt><label for="company_region">Region</label></dt>
<dd>
<select name="company_region">
<option value="">[Select One]</option>
<optgroup stl:repeat="region create_form/regions"
label="${region/label}">
<option stl:repeat="county region/counties"
value="${county/id}">${county/label}</option>
</optgroup>
</select>
</dd>
</dl>
<!-- This form is for the UK only -->

<!-- Non UK States, teritories or provinces form starts here -->

<dl id="dl_address_country">
<dt><label for="address_country">Country</label></dt>
<dd>
<input size="40" name="address_country" />
</dd>
</dl>
<dl id="dl_address_region">
<dt><label for="address_region">Region/State</label></dt>
<dd>
<input size="40" name="address_region" />
</dd>
</dl>
<dl id="dl_address_county">
<dt><label for="address_county">County</label></dt>
<dd>
<input size="40" name="address_county" />
</dd>
</dl>

So, what I would like is that if a User clicks on the UK - radio
button only the first part of the form is shown and hide the second
part and vice a versa, when a User clicks on Non - UK radio button the
second part of the form is show and the first is hidden.

Any advise will be much appreciated.

Many thanks

Norman

Feb 20 '07 #1
6 4177
I haven't got time to go through your code but here's how I did it a
few days ago

markup (I couldn't get it to work with the onclick in an external js
file for some reason):

<input type="radio" name="gymspashop" id="gymspashop" value="Gym"
checked="checked" onclick="Radio(this);"Gym
<input type="radio" name="gymspashop" id="gymspashop" value="Spa"
onclick="Radio(this);"Spa

js:
function analyseRadio(rad) {
if (rad.value == "Spa") {
document.getElementById('contactcontext-spa').style.display = "block"
document.getElementById('contactcontext-gym').style.display = "none"
}
etc
}

Feb 20 '07 #2
spot the typo. should read onclick="analyseRadio(this)

Feb 20 '07 #3
On Feb 20, 3:09 pm, brough...@gmail.com wrote:
spot the typo. should read onclick="analyseRadio(this)
Hi thanks for your reply, but I couldn't get it to work...

Do I need to give the id=contactcontext-spa or contactcontext-gym for
the differnt input values, please if you can send me the full example.

Cheers

Norman

PS Also, I found http://www.quirksmode.org/dom/usableforms.html, could
be of help...

Feb 20 '07 #4
On 20 Feb, 09:49, "Norman" <norman.kh...@gmail.comwrote:
On Feb 20, 3:09 pm, brough...@gmail.com wrote:
spot the typo. should read onclick="analyseRadio(this)

Hi thanks for your reply, but I couldn't get it to work...

Do I need to give the id=contactcontext-spa or contactcontext-gym for
the differnt input values, please if you can send me the full example.
example here:

http://tinyurl.com/37fbhj

Feb 20 '07 #5
did I just paste the wrong tinyurl...

http://tinyurl.com/37fbhj

assign each radio button a unique value -- this value will be passed
on by the onclick event to the radio() function. As the radio buttons
themselves are an array each shares the same name and id.

the div 'contactcontext-spa' in this example is the name of the div
that is to be revealed or hidden.

Feb 20 '07 #6
On Feb 20, 5:40 pm, brough...@gmail.com wrote:
did I just paste the wrong tinyurl...

http://tinyurl.com/37fbhj

assign each radio button a unique value -- this value will be passed
on by the onclick event to the radio() function. As the radio buttons
themselves are an array each shares the same name and id.

the div 'contactcontext-spa' in this example is the name of the div
that is to be revealed or hidden.
Thanks for your help, I got it to work ;)

Feb 20 '07 #7

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

Similar topics

13
73970
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
2475
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...
9
2737
by: sergio | last post by:
Hi all, I have created the following script that will show/hide a menu based on checkboxes. It works fine in Opera but not on IE6! Does anybody knows a workaround this problem? Thanks for your...
3
2239
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
36558
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...
0
1395
by: Mac via DotNetMonster.com | last post by:
I have a MDI parent form and the only control on it is a panel anchored to the left hand side. I have menu items on the MDI parent that show & hide this panel. Ideally I would like it to show by...
0
4736
by: question | last post by:
Hi! I have a requirement where I need to display multiple forms one after the other like a slide show. These are in the same application. Basicall on selection of a menu item it should start...
5
8411
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...
1
4150
by: pamate | last post by:
hi, I want to show hide layers. I am able to show and hide layers but i am facing problem that, cant view the cursor in Mozilla,but i can type in input text box, its overlapping the layers. ...
1
3782
oranoos3000
by: oranoos3000 | last post by:
hi would you please help me i have a online shopping center that i show pictures of the my product in home page. in the InterExplorer pictures is shown correctly but in Firefox browser is shown...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
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
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7468
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...
1
5023
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...
0
3170
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
401
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.