Hi,
I am using the following peice of code to show/hide a div tag:
<a href="#" id="pform-show" class="showLink" onclick="showHide(\'pform\');return false;">Contact us about this product</a>
Once clicked it shows the form, if the form is submited but has errors the page reloads, but the div is closed. Is there away to make it open the div tag after the form is submited so the missed fields can be corrected and/or the success message be displayed?
Thanks
show/hide div +form
Moderator: General Moderators
-
bob_the _builder
- Forum Contributor
- Posts: 131
- Joined: Sat Aug 28, 2004 12:25 am
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: show/hide div +form
Moved to Client Side.
Can you show your JS code that does the showing and hiding?
Can you show your JS code that does the showing and hiding?
-
bob_the _builder
- Forum Contributor
- Posts: 131
- Joined: Sat Aug 28, 2004 12:25 am
Re: show/hide div +form
Hi,
Javascript is:
Thanks
Javascript is:
Code: Select all
function showHide(shID) {
if (document.getElementById(shID)) {
if (document.getElementById(shID+'-show').style.display != 'none') {
document.getElementById(shID+'-show').style.display = 'none';
document.getElementById(shID).style.display = 'block';
}
else {
document.getElementById(shID+'-show').style.display = 'inline';
document.getElementById(shID).style.display = 'none';
}
}
}- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: show/hide div +form
Change Class Function
Using Change Class Function
Set Style By Id Function
Using Set Style By Id Function
Code: Select all
// Class Changefunction change(id, newClass){identity=document.getElementById(id);identity.className=newClass;} Code: Select all
change('my_id', 'my_new_class');Code: Select all
function setstylebyid(i, p, v) {var n = document.getElementById(i);if (n != null) {n.style[p] = v;}}Code: Select all
setstylebyid('my_id_1', 'display', 'none');setstylebyid('my_id_2', 'color', '#123cdf');setstylebyid('my_id_3', 'border-left', '#123 solid 1px');