This topic is locked

Change field to disabled is driving me crazy

6/30/2008 3:49:25 AM
PHPRunner General questions
M
marpunta author

Hi i am using PHPR 4.2 and i want to disable some fields in the ADD or EDIT forms when a value from a field is selected

To be more specific i have created a test database with only one table with five fields

The first field is edited as a radio button with 3 options

I tried Jane's example with my own field names and is something like that

{literal}<script>

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

{

if(document.forms.editform.value_alpha.value=='1') //this is the actual value

{

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

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

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

}

else

{

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

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

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

}

}

</script>{/literal}


I added that at the end of ADD page just before the <body> <html>
BUT NOTHING HAPPENS!!!
What might be wrong???
As i said the project is a test so no other code is added anywhere
And another thing if my page has only inline add and inline edit options where should i put the code?
please help <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=8880&image=1&table=forumtopics' class='bbc_emoticon' alt=':blink:' />

J
Jane 6/30/2008

Hi,
code for dropdown doesn't work for radio button.

You need to edit generated include/commonfunctions.php file for this purpose. Find BuildRadioControl function and edit following line:

echo "<input type=\"Radio\" name=\"radio_".$cfieldname."\" onclick=\"java script: $('#".$cfieldid."')[0].value='".htmlspecialchars($opt)."'; return true;\" ".$checked.">".htmlspecialchars($opt)."
";

M
marpunta author 6/30/2008

Hi Jane
I know nothing about php not to mention java
So if you can please tell me what exactly do i have to edit
And second if i change radio button sellection with a drop down menu

will the code you mentioned earlier work??
Thanx <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=30663&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />

J
Jane 7/1/2008

Hi,
yes, this code will work for dropdown box.
Regarding the radiobutton.

Please publish your project on the Demo Account and send link to your pages to support@xlinesoft.com. I'll try to help you.

M
marpunta author 7/1/2008

Thank you
The drop down option is working fine
But if you bare with me i have another question
How can i copy a value from a field to another field of the same record in the same table

After the record has been added
Example:

I add a record

Field1=value1

Field2=value2

Field3=(this field is read only)
So after the record has been added i want the value of field1 to be copied to Field3
Thank you again

J
Jane 7/1/2008

Hi,
use Before record added event on the Events tab for this purpose.

Here is a sample:

$values["Field3"] = $values["Field1"];

M
marpunta author 7/1/2008