BullGuard Antivirus Sale - 60% Off with openElement !
Forum Home Forum Home >

openElement

> openElement General Discussion
  New Posts New Posts RSS Feed - Code Block execution
  FAQ FAQ  Forum Search   Register Register  Login Login

Code Block execution

 Post Reply Post Reply Page  <12
Author
Message
uzes90 View Drop Down
Newbie
Newbie
Avatar

Joined: Mar 31 2019
Location: NYC
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote uzes90 Quote  Post ReplyReply Direct Link To This Post Posted: Mar 31 2019 at 9:55pm

Don't see how that would matter as there's the basic issue of the code not being executed "on click". It's executed when the page loads and that's it.
But, I made the change and added "select"... no difference.

Is there some documentation or tutorial on executing code blocks?
I know I'm a newbi to this app but I have much experience coding etc. and this just doesn't make sense to me. I'm missing something... or its just not doable.

I do appreciate your time trying to help me.
Back to Top
Hobby001 View Drop Down
Admin Group
Admin Group
Avatar

Joined: Jun 05 2018
Location: Canada, Québec
Status: Offline
Points: 6209
Post Options Post Options   Thanks (0) Thanks(0)   Quote Hobby001 Quote  Post ReplyReply Direct Link To This Post Posted: Mar 31 2019 at 10:32pm
Sorry, my mistake,  I'm about to leave for more than a week therefore I'm trying to do everything in the same time

I used: 

$(function(){
$('#WEbutton').click(
function(){
window.open( $('#WEdropList select').val(), '_blank');
}
);
})

On this page and it work fine for me.





Edited by Hobby001 - Mar 31 2019 at 10:34pm
Back to Top
uzes90 View Drop Down
Newbie
Newbie
Avatar

Joined: Mar 31 2019
Location: NYC
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote uzes90 Quote  Post ReplyReply Direct Link To This Post Posted: Mar 31 2019 at 11:13pm

Sorry, doesn't work for me.  But perhaps "works" is in the eye of the beholder.
It will change pages for me depending on which drop-down I click. But it won't do this on the button-click of a button object on the same page as the drop down.

An explanation of where the "code block" is calledd would really help.

Thanks
Back to Top
brolysan View Drop Down
Admin Group
Admin Group
Avatar

Joined: Aug 05 2016
Status: Offline
Points: 2128
Post Options Post Options   Thanks (0) Thanks(0)   Quote brolysan Quote  Post ReplyReply Direct Link To This Post Posted: Apr 01 2019 at 11:30am
The code can be adapted to your needs, but remember, Hobby001 is also a volunteer (like all of us). Thank you
http://sensode.com
Back to Top
uzes90 View Drop Down
Newbie
Newbie
Avatar

Joined: Mar 31 2019
Location: NYC
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote uzes90 Quote  Post ReplyReply Direct Link To This Post Posted: Apr 01 2019 at 1:10pm

Hi-

Of course I understand he's a volunteer, and I appreciate all the help he's provided.
And openElement seems to be a great app that I was able to use very nicely so far. I like it.

Yet... I keep asking the same question... how to use code-block... and no one is able to give me an answer. I wish I could get an explanation on how a code block gets called.

The closest I've been able to get is that it can be called from a button object by going to the Link Configuration section, choosing "JS:" in the drop down instead of chosing a link, and then adding the name of my code block. However, on execution I get an error saying it can't find the reference to my code block.

Again, thank you all for your help.


Back to Top
Hobby001 View Drop Down
Admin Group
Admin Group
Avatar

Joined: Jun 05 2018
Location: Canada, Québec
Status: Offline
Points: 6209
Post Options Post Options   Thanks (1) Thanks(1)   Quote Hobby001 Quote  Post ReplyReply Direct Link To This Post Posted: Apr 01 2019 at 1:29pm
Sometime it's harder to understand the question than to answer it.

I added the following function called OpenHomePage to a javascript source code:

function OpenHomePage(){
window.open('/index.htm', '_blank'); 
}

Then linked it to your button by writing the function's name to it.



Edited by Hobby001 - Apr 01 2019 at 1:29pm
Back to Top
uzes90 View Drop Down
Newbie
Newbie
Avatar

Joined: Mar 31 2019
Location: NYC
Status: Offline
Points: 18
Post Options Post Options   Thanks (1) Thanks(1)   Quote uzes90 Quote  Post ReplyReply Direct Link To This Post Posted: Apr 01 2019 at 2:42pm
Hi-
Thanks for the clear example.
I did exactly as you said... and IT WORKED !

I traced my last error back to a missing semi-colon in the JS: definition.
I'm on my way...
Thanks for all your help !!!



Edited by uzes90 - Apr 02 2019 at 2:33pm
Back to Top
uzes90 View Drop Down
Newbie
Newbie
Avatar

Joined: Mar 31 2019
Location: NYC
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote uzes90 Quote  Post ReplyReply Direct Link To This Post Posted: Apr 03 2019 at 3:29am

Hi All,

I thought I would continue this thread as a sort of tutorial.  The Admins can move it there if they see fit.  I spent a lot of time getting this stuff to work with the help of the Hobby001. I’d like to try and give something back.

I learned quite a bit about how to do things in a code-block –

  1. How to write a code block – easy enough
  2. How to call it – quite tricky, but thanks to the good explanation from Hobby001 it worked!  I was calling the code block from a “myButton”.  When the button was pressed, the validation would occur. But I needed set this up properly under the “Link” section of the myButton. (See his nice screen shot a few responses back.)
  3. How to get a simple “if” statement to work –more difficult than it should have been
  4. How to get input from a text page -- this was truly a “eureka” moment. I don’t know if it’s my inexperience with JavaScript…
  5. How to call another web-page. This was initially quite easy, but then took a turn when it wouldn’t work after being published.

The code-block is supposed to get a value from a drop-down list and call a corresponding web page if the input field or password is valid.  Note that in the example below, I don’t check for a password (myInputField) for the secondd drop-down element.

Initial version of the code block:
function gotoMyCodeBlock(){
    if ( $('myDropDownList select').val()=='1'
        && $('myInputField’).val() =='1') {
        window.location = 'situation1.htm';                    
    } else if ( $('myDropDownList  select').val()=='2') {
        window.location = 'situation2.htm';
    } else {
        window.location =  'page25.htm';
    }

 

I learned that I could not use my fieldnames and needed to use the code ID’s, i.e. “WE” field names.  Then, to get input from “myInputField”, JavaScript needed the “input” parameter.  Finally, to switch to a new web-page, the “windows.location=<page name> worked fine in “Preview” mode. But when I transferred it to the actual web-server, I kept getting 404 errors. To get around this I could specify the entire page address, i.e. c:\aaa\bbb\www\page25.htm.  But then I found that this trick would work - OE.Navigate.open(event,'situation2.htm',1).

 

Final version of the code:

function gotoMyCodeBlock (){
    if ( $('#WE9d9b5e5188 select').val()=='1'
        && $('#WE3ba56be448 input').val() =='1') {
            OE.Navigate.open(event,'situation1.htm',1)
    } else if ( $('#WE9d9b5e5188 select').val()=='2') {
        OE.Navigate.open(event,'situation2.htm',1)
    } else {
        OE.Navigate.open(event,'page25.htm',1)
    }
}

HTH,

uzes90

Back to Top
 Post Reply Post Reply Page  <12
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.063 seconds.