This topic is locked

expand and collapse foldable section based on variables

10/8/2011 6:03:06 AM
PHPRunner Tips and Tricks
A
acpan author

In before process event of contact_add.php, add this :
// initialise the variables first

echo "<script>

window.expand_section1 =0;

window.expand_section2 =0;

</script>";
// Below when receive htp://..../contact_add.php?expand1=1, it will set the javascript varaibles expand_section1 to 1
if (isset($_REQUEST["expand1"]))

{

echo "<script>

window.expand_section1 =1;

</script>";

}
// in javascript onload event
if (expand_section1 == 1 )

{

$("#section_Section1_s_1").show();

$("#section_Section1_s_1"+"Butt").attr("src", 'images/minus.gif');
$("#section_Section1_s_2").hide();

$("#section_Section1_s_2"+"Butt").attr("src", 'images/plus.gif');

}
// How to use it?

Let say in another list table say, contact_list.php:
Table List:

id, gender, add_link

// add_link is a http link that jump to contact_add.php
if gender is female: set the link to: contact_add.php?expand1=1

if gender is male: set the link to: contact_add.php?expand2=1
So if the contact is a female, then we can add details with section 1 expand while section 2 is collapsed.