Setting Input Value with a Variable at set interval - setinterval

I have an HTML input text box and I am trying to use Javascript to display a live clock inside this text box (ie. use a script to update the current time every second, and insert this current time into the value=""
To do this, I have a javascript function startTime() running to grab the current time in 00:00:00 format. Then I'm using another function setInputValue() to make the results of function startTime() as the "value" of the input text box
This works and displays the current time inside the text box, as expected.
Since this only displays the time that the scripts were loaded, I need a setInterval() to make it update every second. Unfortunately, adding var t = setInterval(startTime, 1000); does not do it. I've also tried setInterval(setInputValue, 1000); and that does not change the time each second, either.
I'm pasting my code here on this link: https://www.w3schools.com/code/tryit.asp?filename=G1B141Z87FCF
Edit to add: While there are probably easier methods than making the end result the value of an input text box, I am having to do it this way because this "live time" will be displayed as an overlay on a video stream. The only way I have access to editing the text of this video overlay is by changing the "value" of the text box. It all works to display the time, it's just not changing each second unless I manually refresh the script.
Thank you for any help you could provide.

Related

Blue Prism Write to Web Client

Has anyone had any problems writing data to a web client data field?
Having spied the field to be written in, the write action correctly writes the value from the data item into the web field. We then "Save" the value in the field by clicking the Save button. This is when the value reverts back to the value that was previously in the field and does not save the new value.
Copying the value from the data item and pasting it directly into the web field and hitting save works fine, but for some reason when Blue Prism does the write action and then save, the new value is not saved.
Any suggestions?
This is probably due to the way the web application is coded - specifically, the data in the box is not acknowledged until a keydown event (or similar) is fired. When you copy/paste the data into the field, it fires a similar event where it believes the user to have interacted with the field.
The solution for this type of field is to use the Send Keys or Global Send Keys functionalities of Blue Prism to send the desired text.
It happens when the target application uses java script events to sense the changes in the element. To handle this , you have to use the send keys in following format.
1. Focus the application / Control
2. Send Global mouse click centre to the element
3. Send "Sendkeys" to the application now.
4. Focus a dummy element in the page to let the page sense your input.
If the old value is already higlighted when the spied field is selected, try getting BP to delete it first, then paste in the new value, then click on the field again, then save. If this doesn't work, then uncheck the URL attribute of the application model you are using for the spied field and try this again.

Invoke javascript on the change of a document property via a python script

Usecase - There is a python script which changes the value of an input field property control(say input1). Need to invoke a javascript whenever this document property(input1) changes. Tried using the change event in the javascript but it does not trigger the javascript. The javascript triggers only if we manually set a value and click in the text area to submit the value.
Has anyone found a workaround for this? Using Spotfire version 7.0
I have successfully done this by adding a space to the html in the text area via the IronPython script.
#add a space to trigger JavaScript
from Spotfire.Dxp.Application.Visuals import HtmlTextArea
txt.As[HtmlTextArea]().HtmlContent += " "
txt is an input parameter of type Visualization. Make sure this is the Text Area visualization where your JavaScript is that you wish to trigger. If you place this at the end of the python script that is updating the property control it should trigger the JavaScript as it re-renders the Text Area visualization. Hope this helps!

How to disable the whole page?

I have a field where a customer number is required. When the user leaves the field in the onblur event I need to run some code, in this case check if the given number is already in use. The problem is the codes needs some time to complete. For this short period the user should not be able to make any input. Also I'd like to display a gif.
There is a genius snippet on XSnippets called "Standby Dialog" (https://openntf.org/XSnippets.nsf/snippet.xsp?id=standby-dialog-custom-control)
If you implement this on your page (preferably as custom control) you will get an overlay everytime a partial refresh happens. If you init a partial refresh when the user blurs the field you will get what you want.

timer function for xpages xp:messages and hidden input

I am using a hidden input to store a message for displaying a computed value in a hidden input. I add a message string to the hidden input on postSaveDocument to show the document was saved sucessfully. Being new to this coming from classic Notes development I would like to know how to only have this show for a predetermined amount of time, like 5 seconds, and then go away. So how would I change the value of the hidden input to "" after the time lapse from postSave. Many thanks.
There are many ways to do this. One would be to run this CSJS when there is a message in your input field:
setTimeout('dojo.byId("#{id:divMessage}").innerHTML = ""', 5000);
I didn't quite get which element is showing your message (because you are talking about hidden input) but I assumed it's a div or span.
To set input field value you would use:
dojo.byId("#{id:inpMyInput}").value = ""

Watir : How do we capture the subitems displayed by doing mouseover on a particular item

I am trying to work with mouseover on a particular Item in my application by using the following command
{
ie.text_field(:xpath, "//a[contains(text(),'Deal')]").fire_event('onmouseover')
}
On doing mouseover on a item, two subitems are displayed.
Is there any way to capture the sub items which are part of the Item by doing mouseover with which we can report that our test is pass or fail.
Please suggest.
Additional Information :
If we take example,On the StackOver flow page, If i do mouseover on my name, i get a window where i see activity, privileges, Logout and other stuff. This is really what i was looking for. Is there a way to capture the items displayed on the window on doing mouseover.
I also tried to capture the subitems with the following :
{
text=ie.text_field(:xpath, "//a[contains(text(),'Deal')]").fire_event('onmouseover')
puts(text.inspect)
}
On doing this "text" value is displayed as 'nil'.
My general tactic for such things is a combination of using IRB and the IE Developer tool, or Firebug.
using IRB, type out (or cut and paste) the watir statement to fire the onmouseover command to the proper element on the page.
Then have the developer tool rescan the DOM (there's a little refresh icon you can click) The use the tool to point to an element to point to one of the items in the stuff exposed by the onmouseover. Using the info from that, you can then figure out how to address those elements to get the text from the proper div, etc.
If I do that here to the info that opens up when I float the mouse over my name I can find out that it is a table of class "profile-recent-summary" Furthermore I can then look at the way the table is made up and see for example that the 'today' reputation value is in the second cell on that row.. The row also has the text 'reputation' in it.. so
browser.table(:class, 'profile-recent-summary').row(:text, /reputation/).cell(:index, 2).flash
Should flash the cell I want (index might be 1 if using firewatir or webdriver) I can then replace the .flash with something else like .text if I want to get the text from that cell (which is actually inside a link that sits in the cell)..
without seeing your code, I would 'inspect' the element that you are trying to verify and when_present (text) assert that its true

Resources