# Help is needed with Set Widget Value action

**URL:** <https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789>\
**Category:** V4 Question\
**Created:** [September 28, 2014, 9:44pm UTC](https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789 "2014-09-28T21:44:00Z")\
**Posts on this page:** 20\
**Page:** 4

<div class="post-metadata">

**Author:** ![pizzaeilat4](https://forum.sambapos.com/user_avatar/forum.sambapos.com/pizzaeilat4/32/461_2.png) [@pizzaeilat4](https://forum.sambapos.com/u/pizzaeilat4)\
**Post date:** [October 1, 2014, 11:56pm UTC](https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789/61 "2014-10-01T23:56:16Z")

</div>

@QMcKay,  
Yes yes yes yes it works  
Wow thank you thank you thank you thank you 😃  
Now there is the possibility of adding enter?

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [October 1, 2014, 11:56pm UTC](https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789/62 "2014-10-01T23:56:25Z")

</div>

LOL, I can’t even get your page to load in the Widget whether I set it in the Widget or Navigate with the code… it just freezes with that progress bar…

---

<div class="post-metadata">

**Author:** ![Jesse](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jesse/32/61493_2.png) [@Jesse](https://forum.sambapos.com/u/Jesse)\
**Post date:** [October 1, 2014, 11:57pm UTC](https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789/63 "2014-10-01T23:57:25Z")

</div>

> [@pizzaeilat4](#):
>
> Now there is the possibility of adding enter?

The script he posted does the log in as well. You just need to find the ID of it… and if its a button or not.

Example for mine (TimeTrex) I had to change the script

> page.Document.getElementById(“loginForm”).Submit()

to

> page.Document.getElementById(“login\_btn”).Click()

Notice both Submit and LoginForm I had to change

---

<div class="post-metadata">

**Author:** ![pizzaeilat4](https://forum.sambapos.com/user_avatar/forum.sambapos.com/pizzaeilat4/32/461_2.png) [@pizzaeilat4](https://forum.sambapos.com/u/pizzaeilat4)\
**Post date:** [October 1, 2014, 11:59pm UTC](https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789/64 "2014-10-01T23:59:29Z")

</div>

@QMcKay It happens to me on the computer at home  
I think it was caused by all the attempts we made (I’d be happy if you find why this is happening 😉 )  
But on the other computer it works great

---

<div class="post-metadata">

**Author:** ![pizzaeilat4](https://forum.sambapos.com/user_avatar/forum.sambapos.com/pizzaeilat4/32/461_2.png) [@pizzaeilat4](https://forum.sambapos.com/u/pizzaeilat4)\
**Post date:** [October 2, 2014, 12:00am UTC](https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789/65 "2014-10-02T00:00:23Z")

</div>

Thanks @kendash , I’ll try it

---

<div class="post-metadata">

**Author:** ![Jesse](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jesse/32/61493_2.png) [@Jesse](https://forum.sambapos.com/u/Jesse)\
**Post date:** [October 2, 2014, 12:00am UTC](https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789/66 "2014-10-02T00:00:41Z")

</div>

I use firefox so to find the ID i simply right clicked button and chose inspect element. Or you can do it old school and just view the source but i like the easy way myself.

---

<div class="post-metadata">

**Author:** ![Jesse](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jesse/32/61493_2.png) [@Jesse](https://forum.sambapos.com/u/Jesse)\
**Post date:** [October 2, 2014, 12:04am UTC](https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789/67 "2014-10-02T00:04:16Z")

</div>

It’s not letting me like your post anymore I am disappointed. I was going to throw out 3 more likes.

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [October 2, 2014, 12:08am UTC](https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789/68 "2014-10-02T00:08:45Z")

</div>

> [@QMcKay](#):
>
> Also, if the Submit() doesn’t work (it may not, I can’t find the FORM name in the page), instead try:
> 
> page.Document.getElementById(“login-button”).Click()
> 
> or
> 
> page.Document.getElementById(“form”).Submit()

The issue is I can’t find the name of the form in the page (if may just be “form”). But it has a button called `login-button` which should work if you call the `Click()` method…

---

<div class="post-metadata">

**Author:** ![Jesse](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jesse/32/61493_2.png) [@Jesse](https://forum.sambapos.com/u/Jesse)\
**Post date:** [October 2, 2014, 12:10am UTC](https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789/69 "2014-10-02T00:10:51Z")

</div>

try

```
page.Document.getElementById("ext-gen25").Click()
```

---

<div class="post-metadata">

**Author:** ![pizzaeilat4](https://forum.sambapos.com/user_avatar/forum.sambapos.com/pizzaeilat4/32/461_2.png) [@pizzaeilat4](https://forum.sambapos.com/u/pizzaeilat4)\
**Post date:** [October 2, 2014, 12:11am UTC](https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789/70 "2014-10-02T00:11:38Z")

</div>

@QMcKay,  
You are the King 😊  
Thank you so much and good night

---

<div class="post-metadata">

**Author:** ![Jesse](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jesse/32/61493_2.png) [@Jesse](https://forum.sambapos.com/u/Jesse)\
**Post date:** [October 2, 2014, 12:14am UTC](https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789/71 "2014-10-02T00:14:35Z")

</div>

We should so turn this into a tutorial haha. Little sloppy conversation but I am sure someone can use this discussion. This is a great example of integrating AHK with Samba and HTML widget. Ive used AHK in the past and ive watched it evolve into something extremely elaborate. Its nice we could use it for this.

It had been a while since I really looked at AHK so I did not realize the original website is not ran by the main developers anymore. That was good information to find out about [http://ahkscript.org](http://ahkscript.org)

---

<div class="post-metadata">

**Author:** ![emre](https://forum.sambapos.com/user_avatar/forum.sambapos.com/emre/32/39073_2.png) [@emre](https://forum.sambapos.com/u/emre)\
**Post date:** [October 2, 2014, 12:32am UTC](https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789/72 "2014-10-02T00:32:00Z")

</div>

wow wow wow… I was planning to extract a simple keystroke sender action from custom keyboard functions but after seeing the solution I understood that should be done through DOM. Great solution…

> page.Document.getElementById(“username”).Value := “yourusername”  
> page.Document.getElementById(“password”).Value := “yourpassword”  
> page.Document.getElementById(“loginForm”).Submit()

While reading it I’ve remembered something. I’m not sure if it is possible wtih that widget but I think we should be able to execute javascript on loaded html files. I mean we can automate it with SambaPOS. If you think such feature can be useful I can check if it is possible.

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [October 2, 2014, 12:36am UTC](https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789/73 "2014-10-02T00:36:13Z")

</div>

> [@emre](#):
>
> I think we should be able to execute javascript

AHK does support this, I saw it somewhere in my searching, something like:

```
page.execScript("<Javascript Code>")

```

> [@emre](#):
>
> If you think such feature can be useful I can check if it is possible.

You never know how useful it could be until we see it. If implementation isn’t difficult, let us know some possibilities.

---

<div class="post-metadata">

**Author:** ![Jesse](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jesse/32/61493_2.png) [@Jesse](https://forum.sambapos.com/u/Jesse)\
**Post date:** [October 2, 2014, 12:57am UTC](https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789/74 "2014-10-02T00:57:50Z")

</div>

It sounds very useful. I can not directly think of a use right this minute but that also does not mean that I wouldn’t use it if I knew what was possible.

Case and point… I had given up on AHK over a month ago because I couldn’t get this to work. Now that it does work I definitely see how useful it is.

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [October 2, 2014, 1:15am UTC](https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789/75 "2014-10-02T01:15:51Z")

</div>

> [@emre](#):
>
> wow wow wow

😊

> [@Jesse](#):
>
> We should so turn this into a tutorial haha.

I will split this into a Tutorial, specific to `AHK` and `HTML Viewer Widget`. I don’t need this now - I saw it as a challenge and an opportunity to learn something new - but I may need it in the future.

> [@emre](#):
>
> I think we should be able to execute javascript on loaded html files

On the other hand, if @emre lets us use JavaScript in the HTML Viewer Widget, it will probably all be moot, and… BETTER! 😜

---

<div class="post-metadata">

**Author:** ![Jesse](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jesse/32/61493_2.png) [@Jesse](https://forum.sambapos.com/u/Jesse)\
**Post date:** [October 2, 2014, 1:20am UTC](https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789/76 "2014-10-02T01:20:07Z")

</div>

> [@QMcKay](#):
>
> On the other hand, if @emre lets us use JavaScript in the HTML Viewer Widget, it will probably all be moot, and… BETTER!

Better is good 😄

---

<div class="post-metadata">

**Author:** ![emre](https://forum.sambapos.com/user_avatar/forum.sambapos.com/emre/32/39073_2.png) [@emre](https://forum.sambapos.com/u/emre)\
**Post date:** [October 2, 2014, 2:28am UTC](https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789/77 "2014-10-02T02:28:04Z")

</div>

OK. I’ve changed [sambamarket.com](http://sambamarket.com) background color via actions and rules. I think that proves the idea.

 ![](https://forum.sambapos.com/uploads/default/original/3X/9/2/9291f016ec4c3a0212bf039b59ababf61479882f.jpeg) 

What we’ll have ?

- Html Widget Document Loaded Rule. Gives us url.
- Invoke Script action. That executes a js script by it’s name that exists in a html page. For example if your page contains a `Test` function this action executes it.
- and… the nasty `Inject Script` action. This action reads a script from `Automation > Scripts` by handler and injects it into html. So you can execute it with `Invoke Script`.

We can determine which widget to execute by it’s name.

---

<div class="post-metadata">

**Author:** ![Jesse](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jesse/32/61493_2.png) [@Jesse](https://forum.sambapos.com/u/Jesse)\
**Post date:** [October 2, 2014, 2:31am UTC](https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789/78 "2014-10-02T02:31:30Z")

</div>

I could definitely use that. It allows me to do some things I wanted to do with TimeTrex for sure. And it more than likely will allow me do things I need that I have not realized yet 😛

---

<div class="post-metadata">

**Author:** ![emre](https://forum.sambapos.com/user_avatar/forum.sambapos.com/emre/32/39073_2.png) [@emre](https://forum.sambapos.com/u/emre)\
**Post date:** [October 2, 2014, 2:45am UTC](https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789/79 "2014-10-02T02:45:34Z")

</div>

Update: I’ve also added basic support for parameters so we’ll be able to pass values into scripts.

it accepts `color` parameter.

 ![](https://forum.sambapos.com/uploads/default/original/3X/7/b/7b2852c71aa74c3fef5042c8d3e99add7449cb95.jpeg) 

and we add parameter like that. I think we’ll be able to use printing tags here.

 ![](https://forum.sambapos.com/uploads/default/original/3X/3/e/3e43a3d59b072d5b8c9e54756d31dceaa021b993.jpeg) 

It changes to blue.

 ![](https://forum.sambapos.com/uploads/default/original/3X/4/2/4202ce4b949acb01f82f36821f5404e8971b7ca7.jpeg)

@QMcKay Thank you very much for the inspiration. I can imagine how we’ll be able to improve that to create amazing integrations.

---

<div class="post-metadata">

**Author:** ![Jesse](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jesse/32/61493_2.png) [@Jesse](https://forum.sambapos.com/u/Jesse)\
**Post date:** [October 2, 2014, 2:49am UTC](https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789/80 "2014-10-02T02:49:19Z")

</div>

I am already prepping some stuff for my TimeTrex integration. I am thinking automating a lot of cool stuff. I am right now planning on paper an integration that will allow me to use Samba to enter schedules for my employees that will get sent to Timetrex. Each employee will be able to view their own schedule through SambaPOS.

I am also preparing to allow them to request time off through SambaPOS and it will send it to TimeTrex. So I am definitely interested in this. Very cool to know this is possible.

[Previous page](https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789.md?page=3)

[Next page](https://forum.sambapos.com/t/help-is-needed-with-set-widget-value-action/2789.md?page=5)
