Focal Point
[SOLVED] Setting Input Field Values in Maintain

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/7487048096

October 12, 2018, 07:06 PM
mbondr
[SOLVED] Setting Input Field Values in Maintain
Let's say I have a text box or a label and I want to set its value, in real time, the control updating each time I set it. What I'm trying to do is display the selected row number of a grid control. I tried dragging FocIndex into a text box, which displays the initial value, but doesn't update.

This message has been edited. Last edited by: mbondr,


WebFOCUS 8.2.04 (and climbing)
Windows 10, AppStudio
October 17, 2018, 01:08 PM
FP Mod Chuck
mbondr

Since no one has had any suggestions I think you should open a case with techsupport if it is still an issue.


Thank you for using Focal Point!

Chuck Wolff - Focal Point Moderator
WebFOCUS 7x and 8x, Windows, Linux All output Formats
October 18, 2018, 10:46 AM
Deana
I use javascript to set the value in of my control text box when the grid row is selected using the grid either the OnLClicked or OnRClicked event handlers.

here is an example
var dg = document.FormName.GridName;
var currRow = dg.GetCurrentRow();
document.FormName.TextBoxName.value = currRow + 1;

I apologize for not responding sooner. I was out of the office last week did not see your original post.


WebFOCUS 7.6.8 and 7.7.03; Windows Server 2003 R2 and Windows Server 2008 R2, respectively; Development environments - Windows Server 2003 R2 and Windows 7 Professional, respectively;
excel, html, pdf
October 18, 2018, 01:34 PM
mbondr
I couldn't get to the grid using:

document.Form1.grid1

but I could get to it using:

document.getElementById('grid1');

but then I couldn't get to dg.GetCurrentRow();
Using the automatically defined 'ctrl' object seems to work, but then document.Form1.edit1.value fails to find the attribute 'value'.


WebFOCUS 8.2.04 (and climbing)
Windows 10, AppStudio
October 19, 2018, 08:27 AM
Maintain Wizard
When using the grid, we can get information using JavaScript or by heading back to the Maintain code. If you just want to see the current row number you can do this:

1) Create your grid and populate it with a stack
2) Create a variable in your Maintain code and drag it onto the form
compute showme/i3;
by default, this field is named edit1. You can change it in the properties panel if you want.

3) Click in the grid, display it's properties panel and click on the lightening bolt.
4) Select an event. I chose Left Clicked
5) Add the line: edit.value = row+1;
edit1 is the name of your field, while row is a variable passed into this event (alone with col, etc...)
We add 1 because JavaScript starts on row 0.

function grid1_onlclicked(event, col, row, updn, processed) {
var eventObject = event ? event : window.event;
var ctrl = eventObject.target ? eventObject.target : eventObject.srcElement;
// TODO: Add your event handler code here
edit1.value = row+1;
}

That's it. When you run now, when you click on the form, the value changes and you can use the value of showme back in your Maintain code.

Mark
October 19, 2018, 09:59 AM
Deana
I have figured out a rhyme or reason for using document.Form1.grid1 vs document.getElementById('grid1');

If the first way doesn't work, I try the second and am usually successful. Have you tried setting the value using

document.getElementById("edit1").value

I hope this is helpful.


WebFOCUS 7.6.8 and 7.7.03; Windows Server 2003 R2 and Windows Server 2008 R2, respectively; Development environments - Windows Server 2003 R2 and Windows 7 Professional, respectively;
excel, html, pdf
October 19, 2018, 02:52 PM
mbondr
Although I get no error, I can't get the text in the textbox to appear. This is what I'm trying now:

//Begin function grid1_onrowchange
function grid1_onrowchange(event, row, newRow) {
document.getElementById('text1').value = newRow + 1;
}
//End function grid1_onrowchange

It might be setting it. Is there a "refresh" method?


WebFOCUS 8.2.04 (and climbing)
Windows 10, AppStudio
October 19, 2018, 04:57 PM
mbondr
Ah! I figured it out. "value" doesn't cut it. A text box manifests on the page as a span. I switched to "innerHTML" and it worked!


WebFOCUS 8.2.04 (and climbing)
Windows 10, AppStudio