Learn how to a build a cloud-first strategyRegister Now


Change Event Action OnClick

Posted on 2012-08-20
Medium Priority
Last Modified: 2012-09-07
Our seat maps are currently designed to take users to a screen where they can select a seat they want and from there, purchase a ticket. Using the same page, I added a query string that is set for users who want to view the seat maps only and not actually purchase a ticket. Here is the query string I created, you will notice the features I want to disable when they are in "ViewOnly Mode":

 Mode = Request.QueryString["Mode"];
                if (Mode == "ViewOnly")
                    SelectPerformanceBlock.Visible = false;
                    QueueBlock.Visible = false;
                    MaximumTixBlock.Visible = false;
                    LegendHeaderBlock.Visible = false;

Open in new window

I want to include a function after users selected their zone, send them to a page that shows the view from their selected seat. This "view from seat" feature is currently enabled on the page but can only be accessed if users manually click the link. The view from seat feature uses an OnClick function and is written in java-script. My question is how can I enable the "view from seat" function to automatically be displayed when users are in ViewOnly Mode?
Question by:is_staff
  • 4
  • 3
LVL 19

Expert Comment

ID: 38315602
If I'm understanding you well, you need to call a javascript function when entering a page on a determinated state, and this function, usually, fires when clicked on a link.

You can do the following:
On the page, add a listener to body's onLoad event.
On that event firing, you can check if the page is on ViewOnly mode. If this ViewOnly mode is only visible from server code, you can push this value to a hidden input object on your page when loading and read this value directly from javascript.

if the page is on ViewOnly mode then you call the function or directly fire the onClick event of the link (both actions will do the same), if the page isn't on ViewOnly mode exit onLoad listener.

On those cases where there's no ViewOnly mode, the onClick event listener still will be there, ready to enter on "view from seat" when the click event is fired.

Author Comment

ID: 38316482
Thank you for your response. Yes that is correct.

Is there an example you can share with me?
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 19

Expert Comment

ID: 38316526
Initially it's something quite easy... is there anything in particular with wich you have trouble? I can try to sketch it up a bit in a code snippet...

Author Comment

ID: 38316552
I'd like to see how to directly fire the onClick event of the link please and thank you.
LVL 19

Accepted Solution

Bardobrave earned 1500 total points
ID: 38319195
You can do it in two ways:

1) The easiest way is to call the same function that the onClick event is calling, supose your click event calls a enterViewFromSeat function, then on your onLoad event you only need to call the same function:

function onLoadListener() {
   if (document.getElementById("yourViewOnlyModeElementId").value == true)

2) The second way you can do it is launching the click event:

function onLoadListener() {
   if (document.getElementById("yourViewOnlyModeElementId").value == true)

I personally recommend the first one, as event bubbling could be troublematic in some cases.

Author Comment

ID: 38324568
Okay. I'll give it a try and let you know how it goes. Thanks!

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month20 days, 23 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question