This topic is locked

can I lock the id drop down to master id

2/22/2008 2:36:31 AM
PHPRunner General questions
B
bertchal author

Hi,
can I lock the drop down list which is link to master, to the master ID chosen? (when chosen)
why do i want this?
currently default setup of an id with lookup wizard linked to master table behaves like this:

  1. clicking Add New when no master chosen gives full list in drop down and it is acceptable if user chooses any item in this list
  2. however clicking Add New when master WAS chosen the user still gets the full list and can select another item in list. If they do

    PHPRunner keeps pointing this new detail record at the 'old', chosen master record id. Hence they don't get what they expect and are unaware of the 'change'

    I'm thinking the best solution is to lock the item list to the master chosen (when chosen)
    P.S. I have moderate experience with coding events.
    thanks for any help you can provide

J
Jane 2/22/2008

Hi,
use Javascript code for this purpose.

Proceed to the Visual Editor tab, turn on HTML mode, find this line:

{include_if_exists file="include/footer.php"}



and add following code just before:

{literal}<script>

if (document.forms.editform.value_FieldName.value!="")

document.forms.editform.value_FieldName.disabled=true;
document.forms.editform.value_FieldName.onchange=function()

{

if (document.forms.editform.value_FieldName.value!="")

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

}

{/literal}</script>



where FieldName is your actual field name.

B
bertchal author 2/22/2008

WOW that was a quick response. And with Javascript, hmm difficult. But I shall try my best. thanks Jane.

B
bertchal author 2/24/2008

Thanks Jane, that worked a treat.

B
bertchal author 2/26/2008

Thanks Jane, that worked a treat.


Well not quite...

Edit works fine but adding a record does not save the new foreign key (master id). i just get NULL for master ID in the db, no errors, not even js error
can you suggest anything please.

J
Jane 2/26/2008

Hi,
it's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and send to support@xlinesoft.com a URL to your pages along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.

B
bertchal author 2/27/2008

Hi
I worked out all i needed was
{literal}<script>

if (document.forms.editform.value_SiteID.value!="")

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

</script>{/literal}
where SiteID is the foreign key.
so all solved!
thanks for leading me in the right direction.