Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Setting Input Field Values in Maintain
Go
New
Search
Notify
Tools
Reply
  
[SOLVED] Setting Input Field Values in Maintain
 Login/Join
 
Gold member
posted
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
 
Posts: 84 | Registered: February 08, 2018Reply With QuoteReport This Post
Virtuoso
posted Hide Post
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
 
Posts: 1915 | Location: Customer Support | Registered: April 12, 2005Reply With QuoteReport This Post
Gold member
posted Hide Post
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
 
Posts: 82 | Registered: March 19, 2011Reply With QuoteReport This Post
Gold member
posted Hide Post
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
 
Posts: 84 | Registered: February 08, 2018Reply With QuoteReport This Post
Master
posted Hide Post
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
 
Posts: 661 | Location: New York | Registered: May 08, 2003Reply With QuoteReport This Post
Gold member
posted Hide Post
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
 
Posts: 82 | Registered: March 19, 2011Reply With QuoteReport This Post
Gold member
posted Hide Post
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
 
Posts: 84 | Registered: February 08, 2018Reply With QuoteReport This Post
Gold member
posted Hide Post
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
 
Posts: 84 | Registered: February 08, 2018Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Setting Input Field Values in Maintain

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.