This topic is locked

Onload event Script from previous versions don't work on PHPR 6

12/11/2011 4:21:38 PM
PHPRunner General questions
N
Nelson author

Hi,
I have used this script on PHPR 5.2 and it worked...but on PHPR 6.0 the script don't respond.
This script used to work on the "Edit page"!



document.getElementById("hidediv1").style.display="none";
if (document.forms.editform1.value_Category_1.value=="Cars and Light Commercials")

{

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

}

else

{

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";

}

}
if (document.forms.editform1.value_Category_1.value=="Cars and Light Commercials")

document.forms.editform1.value_Category_1.disabled=true;


The URL to the demo account edit page: http://demo.asprunner.net/metallica777_hotmail_com/Icon_Ads_USA/Users_edit__delete_USA_list.php
The only thing it does now, it is hiding the pointed "table-row" all the time regardless of chosen category!
Thanks in advance

S
stiven 12/12/2011

instead of using this if (document.forms.editform1.value_Category_1.value=="Cars and Light Commercials")
try using document.getElemtById
if (document.getElementById('value_Category_1').value=="Cars and Light Commercials")

N
Nelson author 12/12/2011



instead of using this if (document.forms.editform1.value_Category_1.value=="Cars and Light Commercials")
try using document.getElemtById
if (document.getElementById('value_Category_1').value=="Cars and Light Commercials")


Hi Stivens,
Thanks for the help...everything is working now except the last part of the script which suppose to disable the dropdown...so the users can't change the category...but still they can change the category...the script goes like this:

if (document.forms.editform1.value_Category_1.value=="Cars and Light Commercials")

document.forms.editform1.value_Category_1.disabled=true;


I changed it to :

if (document.getElementById('value_Category_1').value=="Cars and Light Commercials")

document.getElementById('value_Category_1').disabled=true;


Still not working..

S
stiven 12/12/2011

im not sure why, can you update the code on the example website you gave us?
also try to using the first conditional it is the same as the last one you don't need another one.



if (document.getElementById('value_Category_1').value=="Cars and Light Commercials")

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

document.getElementById('value_Category_1').disabled=true;



I don't have much experience with javascript sorry, update the code on the website and maybe i can get an idea of what is wrong, also try to see the errors it gives or maybe it is because you're trying to disable the same element you are using as the reference??
I also just noticed all 3 conditionals depend on the same value why have 3 and not just one for all of them?

N
Nelson author 12/12/2011



im not sure why, can you update the code on the example website you gave us?
also try to using the first conditional it is the same as the last one you don't need another one.



if (document.getElementById('value_Category_1').value=="Cars and Light Commercials")

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

document.getElementById('value_Category_1').disabled=true;



I don't have much experience with javascript sorry, update the code on the website and maybe i can get an idea of what is wrong, also try to see the errors it gives or maybe it is because you're trying to disable the same element you are using as the reference??
I also just noticed all 3 conditionals depend on the same value why have 3 and not just one for all of them?


Buddy that did it..now it works all the way:
The end script became like this;

document.getElementById("hidediv1").style.display="none";
if (document.getElementById('value_Category_1').value=="Cars and Light Commercials")

{

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

document.getElementById('value_Category_1').disabled=true;

}

else

{

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

document.getElementById('value_Category_1').disabled=true;

}

}


Thanks for your help..have a great day