This topic is locked

Disabling Field

11/23/2009 3:06:26 AM
PHPRunner General questions
D
doykoes author

Hi,...
Please somebody help ...

When user select value from dropdown (ex : hours), i want some field in the same form , is disable...

until user save the data...
Thank You...

J
Jane 11/24/2009

Hi,
use custom JavaScript code for this purpose.

Here is a sample:

<script>

document.forms.editform.value_FieldName1.onchange = function()

{

document.forms.editform.value_FieldName2.disabled = true;

}

</script>



To add JavaScript code switch to HTML mode on the Visual Editor tab and add your code at the end of the page.

D
doykoes author 11/24/2009



Hi,
use custom JavaScript code for this purpose.

Here is a sample:

<script>

document.forms.editform.value_FieldName1.onchange = function()

{

document.forms.editform.value_FieldName2.disabled = true;

}

</script>



To add JavaScript code switch to HTML mode on the Visual Editor tab and add your code at the end of the page.


Thank You Jane for your kind,

I tried this script for mutliple fields, but it doesn't works...
This my example ;
<script>

document.forms.editform.value_btipe.onchange=function()

{

if(this.options[this.selectedIndex].value=='xxx')

document.forms.editform.value_x1.disabled=false;

document.forms.editform.value_x2.disabled=false;

document.forms.editform.value_x3.disabled=false;
else

{

document.forms.editform.value_x1.disabled=true;

document.forms.editform.value_x1.value='';

}

}

</SCRIPT>
Please help...

Thank You...

J
Jane 11/25/2009

It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.

J
jsuisman 11/25/2009



<script>

document.forms.editform.value_btipe.onchange=function()

{

if(this.options[this.selectedIndex].value=='xxx')

document.forms.editform.value_x1.disabled=false;

document.forms.editform.value_x2.disabled=false;

document.forms.editform.value_x3.disabled=false;
else

{

document.forms.editform.value_x1.disabled=true;

document.forms.editform.value_x1.value='';

}

}

</SCRIPT>
Please help...

Thank You...


Hey Doykeos,
Not sure if you copy and pasted the exact code you're trying to use, but if you did than your curly braces are not correct. You're missing one after the if clause and before the else
The correct code should be:



<script>

document.forms.editform.value_btipe.onchange=function()

{

if(this.options[this.selectedIndex].value=='xxx')

{

document.forms.editform.value_x1.disabled=false;

document.forms.editform.value_x2.disabled=false;

document.forms.editform.value_x3.disabled=false;

}

else

{

document.forms.editform.value_x1.disabled=true;

document.forms.editform.value_x1.value='';

}

}

</script>


If that doesn't fix it, than it has to be something to do with the if clause.
Jarred

A
aalekizoglou 11/26/2009

Doykeos,
it seems you are missing some {}. Most of the times it is a javascript error. Try using Firefox with Bugzilla extension.
Here is the change



<script>

document.forms.editform.value_btipe.onchange=function()

{

if(this.options[this.selectedIndex].value=='xxx') {

document.forms.editform.value_x1.disabled=false;

document.forms.editform.value_x2.disabled=false;

document.forms.editform.value_x3.disabled=false;

}

else {

document.forms.editform.value_x1.disabled=true;

document.forms.editform.value_x1.value='';

}

}

</SCRIPT>


Regards,

Athanasios Alekizoglou

QUALISYS SOFTWARE

D
doykoes author 11/26/2009

Thank you...thank you