PDA

View Full Version : dependant conditional region using check box


alamask
06-14-2007, 05:07 PM
here is the problem.
I want to have a checkbox and if the user click on the check box then a new dropdown box field will appear on the page without having to reload the page. is there any extension or any script that would do this? im doing mine in ASP VB.

davidj
06-14-2007, 08:02 PM
im guessing your using dreamweaver code to do your ASP. You should learn how to code because you wont need to look for plugins if you knew how

Do this in Javascript...

create your dropdown as normal on the page and wrap it in a <div and giv it an ID <div id="hide". Make the div invisible by using style.visibility="hidden" as an attribute or define an invisibility class

Then just create a JS function

function appear(){
d = document.getElementById('hide');
d.style.visibility="visible";
}

now on the chechbox just add onclick="appear()"

alamask
06-15-2007, 05:29 PM
thank you! that was very clear and i got it to work. i have another question, what if u want to hide it again if u unchecked it? then how do i do it?

davidj
06-15-2007, 06:29 PM
ok make your function abit mor advanced

function hide(){

c = document.getElementById('checkbox');
d = document.getElemenById('dropdown');

if(c.checked == true){

d.style.visibility="hidden";

}else{

c.style.visibility="visible";

}
}

then on your checkbox just fire the function using an onclick event