This topic is locked
[SOLVED]

 Jscript auto fill a dropdown list

9/8/2018 7:19:33 PM
PHPRunner General questions
M
Mark Kramer author

I have an Employee dropdown list field that pulls from the "employee" table and it works fine. On the add page in my Onload event I have the following code to auto file the the employee field when "proj" is checked. It works when I do not choose a dropdown field list but I can't get it to work when I do use one. Is this even possible or am I wasting my time trying to make it work. Here is the working jscript Onload event code .
__

var proj = Runner.getControl(pageid,'Project');

var empl = Runner.getControl(pageid,'EmployeeID');

//Projects

function projfunc() {
if (proj.getValue()=='on')
{

empl.setValue("Projects");
}
}

//End Projects
proj.on('Change',projfunc);



admin 9/9/2018

Everything is possible but I'm struggling to decipher the following:

It works when I do not choose a dropdown field list but I can't get it to work when I do use one


Can you rephrase it?

M
Mark Kramer author 9/9/2018



Everything is possible but I'm struggling to decipher the following:
Can you rephrase it?


If the field is set toadd as a "text" field Jscript inputs the value "Project" as it should but if I change the field to "Lookup wizard" Jscript will not auto input the value. I tried the Editbox with ajax popup and allow free input but I loose the lookup choices.
I was wondering if there was some code way around this..

admin 9/10/2018

What does it mean "Jscript will not auto input the value"?

M
Mark Kramer author 9/10/2018



What does it mean "Jscript will not auto input the value"?


By "auto input" I mean.. I use this command empl.setValue("Projects"); to set the field data to "Projects" in the add record and it works as it is supposed to. The Jscript Code all works perfectly . The problem is when I change the field type from a basic text field to a dropdown box (using the the lookup wizard) is doesn't input the data "Projects" into the field like it does in basic text mode. I'm starting think it is because of the dropdown array is blocking the field input....
As a side Note:
Sergey, I know you hear this all the time because I see all over the place, but this is one excellent "ever evolving" piece of software. I have been exploring all the nooks and crannies over the years and finding new ways to do more cool stuff. It just keeps getting better and better! I actually makes it fun to code. Keep up the great work!

J
jarnurm 9/11/2018

I have exactly the same problem.

admin 9/11/2018

One user posts a problem that cannot be deciphered. Another users chimes in right away "I have the same issue". I love it.
You cannot "input" something into a dropdown list. Dropdown list contains a list of predefined values, you can only select one of existing.
If you need to add a new option to dorpdown box you cannot use setValue(). You can use jQuery:

https://stackoverflow.com/questions/740195/adding-options-to-a-select-using-jquery
If you are talking about "selecting" one of existing options in dropdown list you can use setValue() for this purpose. You just need to remember that if link field field and display field are different in your dropdown box setup you need to use the value of Link field in your code.

M
Mark Kramer author 9/12/2018



One user posts a problem that cannot be deciphered. Another users chimes in right away "I have the same issue". I love it.
You cannot "input" something into a dropdown list. Dropdown list contains a list of predefined values, you can only select one of existing.
If you need to add a new option to dorpdown box you cannot use setValue(). You can use jQuery:

https://stackoverflow.com/questions/740195/adding-options-to-a-select-using-jquery
If you are talking about "selecting" one of existing options in dropdown list you can use setValue() for this purpose. You just need to remember that if link field field and display field are different in your dropdown box setup you need to use the value of Link field in your code.


That was the answered I needed!
Thank you!