Page 1 of 1

show/hide div +form

Posted: Sat May 10, 2008 12:22 am
by bob_the _builder
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

Re: show/hide div +form

Posted: Sat May 10, 2008 1:42 am
by RobertGonzalez
Moved to Client Side.

Can you show your JS code that does the showing and hiding?

Re: show/hide div +form

Posted: Sat May 10, 2008 1:45 am
by bob_the _builder
Hi,

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';
        }
    }
}
Thanks

Re: show/hide div +form

Posted: Sun May 11, 2008 11:05 am
by JAB Creations
Change Class Function

Code: Select all

// Class Changefunction change(id, newClass){identity=document.getElementById(id);identity.className=newClass;} 
Using Change Class Function

Code: Select all

change('my_id', 'my_new_class');
Set Style By Id Function

Code: Select all

function setstylebyid(i, p, v) {var n = document.getElementById(i);if (n != null) {n.style[p] = v;}}
Using Set Style By Id Function

Code: Select all

setstylebyid('my_id_1', 'display', 'none');setstylebyid('my_id_2', 'color', '#123cdf');setstylebyid('my_id_3', 'border-left', '#123 solid 1px');