Change Event Action OnClick

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?
is_staffAsked:
Who is Participating?
 
BardobraveCommented:
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)
      enterViewFromSeat();
}

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

function onLoadListener() {
   if (document.getElementById("yourViewOnlyModeElementId").value == true)
      document.getElementById("yourLinkObjectId").click();
}

I personally recommend the first one, as event bubbling could be troublematic in some cases.
0
 
BardobraveCommented:
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.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
is_staffAuthor Commented:
Thank you for your response. Yes that is correct.

Is there an example you can share with me?
0
 
BardobraveCommented:
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...
0
 
is_staffAuthor Commented:
I'd like to see how to directly fire the onClick event of the link please and thank you.
0
 
is_staffAuthor Commented:
Okay. I'll give it a try and let you know how it goes. Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.