ONSELECT event not populating selectbox

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
ppbedz
Experienced User
Posts: 147
Joined: Tue Jun 17, 2014 4:00 pm
First Name: Patti
Last Name: Bednarz
Company Name: McGard
State / Province: New York
Country: United States
Contact:

ONSELECT event not populating selectbox

Post by ppbedz »

I have The following coded on the ONSELECT event for a database-driven auto-complete text box:
applyProperty("EquipSelect", "choices parameter value", get("VnnoSelect"));
applyProperty("EquipSelect", "field type", "select box");
applyProperty("MfgnoSelect", "choices parameter value", get("VnnoSelect"));
applyProperty("MfgnoSelect", "field type", "select box");

This is supposed to populate 2 select boxes. I know the event is executed because I added a pop-up after the last line to test. I also know that the sql that populates my select boxes based on the parameter from the text box DOES work. The problem is that the select boxes do not get populated unless I return control to my rpg pgm and redisplay the screen.

I have used this technique before and the select box was always populated immediately. The only difference is that my initiator was another select box with the javascript coded on the ONCHANGE event. So, I am guess the text box with the ONSELECT is somehow causing this not to work. I do not want to use a select box; I want the user to be able to zoom in on what they need. What do I need to do to make this code populate my select boxes immediately? Thank you, Patti
Here is the code from one of my select boxes:
Attachments
selectbox.docx
(33.03 KiB) Downloaded 560 times
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: ONSELECT event not populating selectbox

Post by Scott Klement »

I don't see any reason why it'd matter if it's an 'onselect' event?!

Have you looked at the 'network' tab in your browser''s developer tools to see what is being sent/received to IBM i? Have you looked at PUISSNVP to make sure the SQL statement is correct? Have you looked at the job log for the SQL job to make sure there are no errors?
ppbedz
Experienced User
Posts: 147
Joined: Tue Jun 17, 2014 4:00 pm
First Name: Patti
Last Name: Bednarz
Company Name: McGard
State / Province: New York
Country: United States
Contact:

Re: ONSELECT event not populating selectbox

Post by ppbedz »

Scott,

I have not been able to see anything wrong. The sql returns the correct data when the screen redisplays (after control returns to pgm). I am enclosing the entire display file source. If you have a chance, can you take a look? Thank you and have a nice Holiday!!!! Patti
Attachments
screendspf.TXT
(110.11 KiB) Downloaded 65 times
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: ONSELECT event not populating selectbox

Post by Scott Klement »

The problem is that your textbox ("VnnoSelect") has database-driven autocomplete enabled. This changes the html 'value' property (which is what you see on the screen for that widget) to be the vendor name rather than the vendor number.

From our conversation at RPG & DB2 Summit, it sounded like you wanted to learn how to debug this stuff yourself. For that reason, I'm going to spend some time explaining how I went about finding the problem.

First of all, because I don't have access to your system, I had to do some extra work that wouldn't be necessary for you:

1) Your DDS was sent as an SEU printout (rather than sending the actual code directly), so I had to first strip off the headings/footers, and remove the other superfluous bits (sequence numbers on the left, dates on the right, form feeds, etc) so I could load it into a regular DDS member.

2) Compiled the display file

3) Looked at your properties and saw which files/fields were used and created some compatable physical files.

4) Put some test data into the PFs from the last step.

5) Created an RPG program to display the record.

Once I had done all of that, I could reproduce the problem. When I run it, the dropdowns are blank. When I type a new vendor number in the VnnoSelect textbox, they remain blank. Now I'm at the same point that you're at. Here's what I did to troubleshoot it:

1) With the display on my screen, I looked at the PUISSNVP file. The SQL statements start in column 167 of the file, though I can scroll leftto see the widget information, session id, and scroll right to see the remainder of the SQL statement
puissnvp.png
puissnvp.png (33.49 KiB) Viewed 560 times

2) The SQL statements look fine, so I opened the browser's developer tools and went to the network tab. I'm using the Firebug developer tool in Firefox (though, both Chrome and IE also have good dev tools, you don't have to use Firebug, it's up to you.)

Since I knew it'd be making requests of the server any time I changed the vendor number field, I went ahead and did that and I saw requests made to the server to to PUI0009103 program. (I didn't need to know this program name in advance because I could clearly see the requests being made when I changed the vendor number, so it was clear that these were the right ones).

I expanded the 'response' information for these network requests:
firebug_response.png
firebug_response.png (110.76 KiB) Viewed 560 times
Hopefully you can see the error message is "Conversion error on variable or parameter". That seemed strange to me at first because the vendor number should be a value that can easily be converted to numeric. Maybe it's not sending what I expected for the vendor number?

3) I clicked on the "Post" tab in for these requests in my network tool. Post shows which data is being sent to the server. The "p1" variable will be the first parameter value. (If there were a 2nd parameter value it would be p2, etc.)
firebug_post.png
firebug_post.png (86.61 KiB) Viewed 560 times
Oops, here I can see that i"m not submitting the vendor number as originally thought, I'm submitting the vendor name! So now I went back and reviewed the display file and figured out what was happening... it was pretty clear, now, that it's because of the database-driven autoselect. (Though, maybe I should've thought of that earlier, I'm supposed to be an expert after all, but it didn't dawn on me until I saw the vendor name being submitted...)

Hope that this is helpful.
ppbedz
Experienced User
Posts: 147
Joined: Tue Jun 17, 2014 4:00 pm
First Name: Patti
Last Name: Bednarz
Company Name: McGard
State / Province: New York
Country: United States
Contact:

Re: ONSELECT event not populating selectbox

Post by ppbedz »

Scott,

That is VERY helpful and I thank you for your time and explanation! Here is the gotcha... I want the vendor field to be data-base driven auto-complete in case the user does not know the vendor number (which "is" alpha even though we refer to it as "number"). Is there a way to keep the data-base driven auto complete with the vendor name and pass the "vendor number" to the sql?

Also, I apologize for the extra work with the SEU member. How should I save/send the next time?

Patti
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests