aaasam - Tuesday, December 6, 2011 2:47 PM:
I have written a JS event which is loaded at the time the form is loaded.
The JS event is supposed to "get" via the document.thisItem.getProperty("asset_number",""); so I can validate it as a number AND build a URL to obtain an image.
When all this is complete, I load the property for my image field on my form as follows:
document.forms(0).assetBarCodeImg.src=BC_http;
However....... the event never seems to execute (ie: fire off onLoad). If I try and run my form and <RC> to view source, the JS method is there as "function onLoad1()". I scan the rest of the HTML/JS but never see a place that it actually executes the method via a call to "onLoad1()".
Should I be tying the execution of the method to an event on the form field like an "onChange" or "onBlur"?
Or, shouldn't the method automatically run as soon as the form is loaded and/or a new / different value is entered into the corresponding form field?
-Scott
aaasam - Tuesday, December 6, 2011 3:38 PM:
Well... here is the new wrinkle....
1) if the asset_number is already populated because I choose to view the item vs. edit, the form loads, but the bar code JS does not fire because I changed it to an onChange event for the asset_number property.
2) if the asset_number is already populated (from a previous "Add New") and I choose to EDIT the item vs. view.
3) if in EDIT mode and I change the asset_number property, with the onChange on this item, it updates the bar code image, BUT seems to be "one behind" the actual changes.
Here is what I think the answer should be....
- add the JS as an onLoad event to the form to obtain the bar code IF the user goes into view the item.
- add the JS as an onChange event to the asset_number property on the form so if the user EDITS the asset_number on the form the bar code JS will fire??
Thoughts?
aaasam - Wednesday, December 7, 2011 10:38 AM:
RESOLVED!!!
I ended up using an onLoad event for when the form loads to drop in a "invalid bar code" image on the form if blank, otherwise it will convert & display the entered barcode.
Then, I added an onBlur event to the item field to do the same thing.
Works like a charm.
-Scott