Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Dynamic visibilty
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Dynamic visibilty

 Post Reply Post Reply Page  12>
Author
ub3rl337ch3ch View Drop Down
Senior Member
Senior Member
Avatar

Joined: 16 February 2005
Location: Australia
Status: Offline
Points: 341
Post Options Post Options   Thanks (0) Thanks(0)   Quote ub3rl337ch3ch Quote  Post ReplyReply Direct Link To This Post Topic: Dynamic visibilty
    Posted: 28 February 2005 at 12:34am
I know messing with visibility is usually done with javascript, thanks to an overabundance of wizards in frontpage and dreamweaver, but i need to make some fields in a form visible or hidden (or disabled/not)depending on the value selected in a dropdown box. Aside from doing an onchange post/submit, and then doing "if select = blah then blah else..." is there any way to do this? I'd prefer not to have to reload the page whenever its changed. If there isn't, just say, and i'll go suck a lemon... LOL
Back to Top
Phat View Drop Down
Senior Member
Senior Member


Joined: 23 February 2003
Status: Offline
Points: 386
Post Options Post Options   Thanks (0) Thanks(0)   Quote Phat Quote  Post ReplyReply Direct Link To This Post Posted: 28 February 2005 at 1:08am
It sounds like you want to do something like http://www.otrader.com.au/portfolio-management-software/contact.asp
right click and view the source code to see what's going on.

It does not use the onChange event but you can modify it to do that.
Back to Top
ub3rl337ch3ch View Drop Down
Senior Member
Senior Member
Avatar

Joined: 16 February 2005
Location: Australia
Status: Offline
Points: 341
Post Options Post Options   Thanks (0) Thanks(0)   Quote ub3rl337ch3ch Quote  Post ReplyReply Direct Link To This Post Posted: 28 February 2005 at 6:26pm
no, because that just uses onclick to change the visbility. It doesn't actually depend on the value of the radiobutton. what i need is something along the lines of (where field is a select box)
 
style="visibility:<%IF field = company THEN response.write "visible" else response.write "hidden"%>"
 
or at least to have the same effect. changing visibility depending on what has been clicked on is simple, especially since there's the behaviours wizard in frontpage does it for you. I need something that changes visibility depending on what option is selected in a combobox.
I know that i can do it by doing "onchange: submit" on the selectbox, and doing a postback, but i'd prefer not to reload the page.
Back to Top
bootcom View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 February 2005
Location: United Kingdom
Status: Offline
Points: 259
Post Options Post Options   Thanks (0) Thanks(0)   Quote bootcom Quote  Post ReplyReply Direct Link To This Post Posted: 28 February 2005 at 7:08pm
Ah ok, I think I get you. Is this what your looking for ??
 
Basically it calls on a function using the onChange, and if the value is company it will hide that input, or if it is not company it will leave the display. You can modify this for your own needs.
 

<script language="javascript">
function changeVisibility(val){
// If the value of the drop down is company then go ahead and start clearing some of the form fields
if(val == "company"){
// clear the inputs you want
document.getElementById("input1").style.visibility = "hidden";
// or do it this way
document.getElementById("input1").style.display = "none"
return;
}
// If this does not have the value of company, keep the style
document.getElementById("input1").style.display = "";
return;
}
</script>
 
<select name="dropdown" onChange="changeVisibility(this.value)">
 <option value="company">company</option>
 <option value="house">house</option>
</select>

Back to Top
ub3rl337ch3ch View Drop Down
Senior Member
Senior Member
Avatar

Joined: 16 February 2005
Location: Australia
Status: Offline
Points: 341
Post Options Post Options   Thanks (0) Thanks(0)   Quote ub3rl337ch3ch Quote  Post ReplyReply Direct Link To This Post Posted: 28 February 2005 at 8:07pm
 
how do i get that to make something else visible/hidden?
would it be:...?
 
document.getElementByID("corp").style.visibility = "hidden"
 
to make the object with id of corp hidden? or am i missing the point completely?
Back to Top
bootcom View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 February 2005
Location: United Kingdom
Status: Offline
Points: 259
Post Options Post Options   Thanks (0) Thanks(0)   Quote bootcom Quote  Post ReplyReply Direct Link To This Post Posted: 28 February 2005 at 8:58pm
Yeah, thats it except its getElementById("corp") remembering javascript is case sensetive.
 
the visibility = "hidden" makes the element hidden from view.
the display = "none" makes the display = "none" basically shows how the page would look if that element were not there.
 
You haven't missed the point, if you give it a go you will see how it works, Smile
Back to Top
ub3rl337ch3ch View Drop Down
Senior Member
Senior Member
Avatar

Joined: 16 February 2005
Location: Australia
Status: Offline
Points: 341
Post Options Post Options   Thanks (0) Thanks(0)   Quote ub3rl337ch3ch Quote  Post ReplyReply Direct Link To This Post Posted: 02 March 2005 at 5:58pm
thanks, that was *exactly* what i was looking for. It worked a treat.
Back to Top
zMaestro View Drop Down
Senior Member
Senior Member


Joined: 11 May 2003
Location: Egypt
Status: Offline
Points: 1183
Post Options Post Options   Thanks (0) Thanks(0)   Quote zMaestro Quote  Post ReplyReply Direct Link To This Post Posted: 04 March 2005 at 3:16am
will this work on Netscape too, or only IE?
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.