 |
| Author |
Message |
=IceBurn=
Joined: 18 Apr 2007 Posts: 2
|
Date: Wed Apr 18, 2007 3:58 pm Subject: Combining CSS and JavaScript to Save Page Space |
|
|
Hi, this is a nice tutorial (Related tutorial: Combining CSS and JavaScript to Save Page Space), but I have one question...
What if for example the box is checked by default?
As if it is checked when the user access the page, I would like that the hidden field was visible and if he uncheck the box than the field get hidden.
Thank you in advance. |
|
| Back to top |
|
bgetting Online Director
Joined: 08 Jan 2006 Posts: 170 Location: Newport, Oregon
|
Date: Thu Apr 19, 2007 7:36 pm Subject: No problem |
|
|
Simply change this part of the code in that article (in the JavaScript document) from this:
| Code: | if (sourceId.checked){
target.style.display = "block";
} else {
target.style.display = "none";
} |
to this:
| Code: | if (sourceId.checked){
target.style.display = "none";
} else {
target.style.display = "block";
} |
that should reverse the effect. |
|
| Back to top |
|
=IceBurn=
Joined: 18 Apr 2007 Posts: 2
|
Date: Thu Apr 19, 2007 9:14 pm Subject: |
|
|
Thank you for your reply, but is not that simple.
The fact is that the box may or may not be checked...
This is for a shopping cart I'm developing, and I want to use something like this in the admin panel so the admin can set speccial offers.
So the box is checked if the prodduct has a speccial offer and unckecked if does not when the admin access the page to edit the product details.
So if the box is checked it was supposed to the promo price field was visible... but hidden if the box is unchekced...
Reversing the function does not work has expected...
If you have an idea how to do this that would be great. As I'm not that good in JavaScritp as I am in PHP for example.
Thanks in advance. |
|
| Back to top |
|
|
|