This topic is locked
[SOLVED]

 Hide/Show dropdowns scripts on Add/edit page PHPR 6.0 NO

11/5/2011 10:37:10 AM
PHPRunner General questions
N
Nelson author

Hi,
I have made 2 websites with previous versions of PHPrunner where users by choosing category would see other dropdowns options apprear and disappear on the Add/edit page...but the same scripts are not working on the PHPR 6.0
I give you an example of the script:

{BEGIN Reg__date_fieldblock}<TR id=hidediv1 class="runner-row style1 runner-b-addfields">

<TD class=runner-cl></TD>

<TD class="runner-cc runner-cc1">{BEGIN Reg__date_label}

Reg.

Date{END Reg__date_label}</TD>

<TD class="runner-cc alt">

{$Reg__date_editcontrol}&nbsp;

</TD>

<TD class="runner-cr alt"></TD></TR>

{END Reg__date_fieldblock}


[color="#FF0000"]the script put in the <body> of the page just after the <footer>


<script>

//hide all rows

document.getElementById("hidediv1").style.display="none";
document.forms.editform1.value_Category_1.onchange=function()

{

if(this.options[this.selectedIndex].value=='Cars and Light Commercials')

{

document.getElementById("hidediv1").style.display="table-row";

}

else

{

document.getElementById("hidediv1").style.display="none";

}

}

</SCRIPT>


Could you please help me with this...thank you

C
cgphp 11/5/2011

Do you get some error ? Try to debug your code with Firebug.

N
Nelson author 11/6/2011



Do you get some error ? Try to debug your code with Firebug.


No, I recieve no error...

N
Nelson author 11/6/2011

I forgot to mention that the only thing the script is doing right now in a project made by PHPR 6.0 is to hide the row all the time.

It doesn't show it on the change on the chosen category!

C
cgphp 11/6/2011

Try this code:

<script type="text/javascript">

//hide all rows

document.getElementById("hidediv1").style.display="none";
document.forms.editform1.value_Category_1.onchange=function()

{

if(this.options[this.selectedIndex].value=='Cars and Light Commercials')

{

document.getElementById("hidediv1").style.display="block"; // this is the new statement

}

else

{

document.getElementById("hidediv1").style.display="none";

}

}

</SCRIPT>
N
Nelson author 11/6/2011



Try this code:

<script type="text/javascript">

//hide all rows

document.getElementById("hidediv1").style.display="none";
document.forms.editform1.value_Category_1.onchange=function()

{

if(this.options[this.selectedIndex].value=='Cars and Light Commercials')

{

document.getElementById("hidediv1").style.display="block"; // this is the new statement

}

else

{

document.getElementById("hidediv1").style.display="none";

}

}

</SCRIPT>



Still it's not working...

The row is hidden all the time but not shown when changed to the category in the script!

C
cgphp 11/6/2011

Put the JS code in the Javascript onLoad event. Update the js code to:

<script type="text/javascript">

//hide all rows

document.getElementById("hidediv1").style.display="none";
document.forms["editform1"].value_Category_1.onchange=function()

{

if(this.options[this.selectedIndex].value=='Cars and Light Commercials')

{

document.getElementById("hidediv1").style.display="block";

}

else

{

document.getElementById("hidediv1").style.display="none";

}

}

</SCRIPT>
N
Nelson author 11/6/2011



Put the JS code in the Javascript onLoad event. Update the js code to:

<script type="text/javascript">

//hide all rows

document.getElementById("hidediv1").style.display="none";
document.forms["editform1"].value_Category_1.onchange=function()

{

if(this.options[this.selectedIndex].value=='Cars and Light Commercials')

{

document.getElementById("hidediv1").style.display="block";

}

else

{

document.getElementById("hidediv1").style.display="none";

}

}

</SCRIPT>



Cristian,
Sorry man..but it's not working for me...the script gives no effect!

C
cgphp 11/6/2011

Could you post a demo link ?

C
cgphp 11/6/2011

I think that value_Category_1 is an id. Try this version:

//hide all rows

document.getElementById("hidediv1").style.display="none";
document.getElementById("value_Category_1").onchange = function()

{

if(this.options[this.selectedIndex].value=='Cars and Light Commercials')

{

document.getElementById("hidediv1").style.display="block";

}

else

{

document.getElementById("hidediv1").style.display="none";

}

}


Put the code in the Javascript Onload event without script tag.

N
Nelson author 11/6/2011



I think that value_Category_1 is an id. Try this version:

//hide all rows

document.getElementById("hidediv1").style.display="none";
document.getElementById("value_Category_1").onchange = function()

{

if(this.options[this.selectedIndex].value=='Cars and Light Commercials')

{

document.getElementById("hidediv1").style.display="block";

}

else

{

document.getElementById("hidediv1").style.display="none";

}

}


Put the code in the Javascript Onload event without script tag.


Cristian,
Now it works buddy...you made my day!..thanks alot
one last thing: please change this line of the code:

document.getElementById("hidediv1").style.display="block";


To:

document.getElementById("hidediv1").style.display="table-row";


otherwise when one chooses the category the dropdowns appears outside of the table(in firefox and chrome)!
once again..thank you friend! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=62089&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />