View Full Version : Display also if selected="selected"
stevenoi
07-10-2009, 05:23 AM
Hi, I got this awesome code that will display an extra DIV when Custom is selected ( when you click on it ), but when you save, "Custom" will be selected="selected", and than that extra DIV won't show.
function showDiv(){
obj=document.getElementById('custom');
df=document.forms[0];
df[0].onchange=function() {
if(this.value=='custom') {
obj.className='';
}
else {
obj.className='hide';
}
}
}
Hope someone can help me!
GrillMonkey
07-10-2009, 08:27 AM
Not entirely sure what you mean by "Custom" will be selected="selected"
but you can add a or staement to your if
if((this.value=='custom') || selected=='selected') {
If this doesn't help then explain a bit more and we'll see what we can do.
stevenoi
07-10-2009, 09:36 AM
Thanks for the help but it didn't worked :(
I have a select list, and the code will add an extra class to a DIV when the option Custom is selected by clicking on it with your mouse, than I hit the submit button and the form will be send. Now the HTML has changed ;
<option selected="selected">Custom</option>
But then the extra class will not be showed..
¥åßßå
07-10-2009, 10:35 AM
function showDiv(){
obj=document.getElementById('custom');
df=document.forms[0];
df[0].onchange=function() {
if(this.value=='custom') {
obj.className='';
}
else {
obj.className='hide';
}
}
df[0].onchange();
}
¥
stevenoi
07-10-2009, 12:24 PM
Thanks Thanks Thanks!
vBulletin® v3.6.7, Copyright ©2000-2010, Jelsoft Enterprises Ltd.