PDA

View Full Version : Events firing up before time??


ABC123

Mario Prieto
09-08-2004, 10:42 AM
I have the following code an a .a5w page. I hope it posts ok.




dim cMessage as C
cMessage="Not Clicked"
%>

TEST EVENTS



cMessage="Clicked"
%>
>

? cMessage
%>




When I run the page it looks as if the onclickevent fires up or it doesn't fire up at all, and maybe the page is just capturing the change on cMessage.
Is the code right??
What am I doing wrong??
Is this how we are supposed to work with events??

Thanks

The Mexican

Mario Prieto
09-08-2004, 10:45 AM
Previous didn't post correctly.
I am also attaching a picture of my page when it loads.


"head"
"%a5
dim cMessage as C
cMessage="Not Clicked"
%"
"meta name="generator" content="Alpha Five HTML Editor""
"title"TEST EVENTS"/title"
"/head"
"body style="text-align:center""
"p" "input type="button" name="btnChange" value="CHANGE" onclick="%a5
cMessage="Clicked"
%"
""/input""br"
"%a5
? cMessage
%"
"/p"
"/body"

The Mexican

Mario Prieto
09-08-2004, 10:47 AM
Sorry, here is the picture

Cheryl Lemire
09-08-2004, 11:12 AM
Hi Mario,

What exactly is your button supposed to do? What is the end result you are trying to accomplish with the onclick event?

Cheryl

Mario Prieto
09-08-2004, 11:37 AM
This was just to test the events on a button.
When I click on the button I want the cMessage variable to change to "Clicked".

When the page loads the message under the button says "Not Clicked"
What I want is when I click the button the message to change to "Clicked"
I am trying to use the button's onclick event, putting A5 code instead of javascript of VBscript.
Simple as that.

The Mexican.

Edward Larrabee
09-09-2004, 06:29 AM
This web tutorial shows how to use Request.script_name to submit a page back to itself, which allows you to respond to the status of variables. Cascading Selection Lists.

Lenny Forziati
09-09-2004, 08:24 AM
Mario, your difficulty arises because you are trying to program a client-side event using server-side technology.

The button's onClick event fires in the web browser (client side) and must use a client-side language (Javascript). When this event fires, there is no knowledge of Xbasic or A5W code. What your page is doing instead is running the A5W code on the server and then sending the following back to the browser:

"input type="button" name="btnChange" value="CHANGE" onclick=cMessage="Clicked" "

This is not valid HTML syntax and as a result you get a broken display.

What ultimately are you trying to accomplish?

-Lenny

Mario Prieto
09-09-2004, 11:32 AM
I am just experimenting with elements' events. I am learning HTML and I though I could substitute JavaScript code with A5 Web server code.

Thanks for the reply. What is the correct way to respond to elements events using A5 code??
Can we even respond to this events using a5 code instead of Javascript??
I haven't check Edward's suggestion in a previous post, but I will later on today.

The Mexican.

Cheryl Lemire
09-09-2004, 11:33 AM
I think what Mario is trying to do is learn/find out how to use server side events on WAS. In other words, he would like to know how to convert the events that are within a desktop application and use them on WAS.

I have been looking through some of the tutorials and have not yet been able to locate an answer for him, but I am sure you guys know :)

Mario Prieto
09-09-2004, 11:38 AM
After I checked the example I still notice that you are using JavaScript to respond to events. In the example case you coded the onchange event with JavaScript.

I guess we cannot respond to elements events using "%a5 %"
code. If I am wrong please guide me where I can find examples.
Sorry for all this questions but I am really trying to understand all this.

The Mexican

Lenny Forziati
09-09-2004, 11:39 AM
The HTML events cannot use Xbasic, they must use a language supported by the web browser, which currently means Javascipt if you want it to run in all browsers.

What you can do instead hoever is have the onClick event submit the form back to the server and then let the server take an appropriate action via Xbasic. You can see an example of this at http://was.alphasoftware.com/web_applications_demo/default/Dialog_wCascadingLookup.a5w

-Lenny

Mario Prieto
09-09-2004, 11:39 AM
You got it!!!

Gracias Cheryl.


The Mexican

Lenny Forziati
09-09-2004, 08:18 PM
If you're manually coding an A5W page as in this example, there are no "events" per se. Each time your page is requested, it executes the Xbasic code within the tags and sends the result to the browser. Using hyperlinks and forms, you can control the requests sent to the server and have your code do different things based on various conditions. Attached is an example page.

There are two things to note in this example:

I dim the variable "favcolor" before I test it. The first time this page is requested by the browser, the variable will not exist so it must be created before we can work with it. When each of the buttons are clicked, the form is requested again and a value is set for this variable. We could alternatively use eval_valid() to see if the variable exists or not instead of blindly dimming it.
The form action is "". request.script_name is a special variable available to all of your A5W pages that holds the name of the currently running page. By using this as our form action, the form will always submit back to itself, even if the page is renamed, moved to a different directory, included in another page, etc.

-Lenny

Mario Prieto
09-09-2004, 10:16 PM
Thanks, will take a look at it tomorrow.

J T K
05-18-2005, 02:25 PM
I am working off of the WebAppServerDemo template with a cascading lookup that is fired off of the Customer ID instead of the Company name, similar to "Dialog_wCascadingLookup.a5w"

I am trying to use three different web components which are similar to each other, on the same page, one component for Sold From, one for Bill To and one for Ship To. I have changed the variable names on the second component to Customer_Id2, Company2, etc and like wise for the third web component (Customer_Id3, Company3, etc. When the first company is chosen, the rest of the dialogue component populates, but when the second and third Customer_Ids are chosen, the first Customer_Id dropdown updates to the first company in the customer table.

Any ideas on how to stop this from happening?