Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

One button firing another buttons click event

I'd like two submit buttons on a form i have my team building, one above the fold, and one below. I'm getting complaints from my tech team about adding it because it requires some server side coding to make sure the user doesn't click it more than once. Apparently they have it one button, but to add that validation to two would be a problem.

Can you not just call the button the same thing, with the same ID and wouldn't the form treat it as one button?

Another option I thought would be for new button to fire a click even on the other button. Then they still have one click even for the form, but I get my two buttons. How would I write that?

Thanks, Adma

like image 797
Adam Avatar asked Sep 23 '11 16:09

Adam


People also ask

Is button click an event?

The Click event is raised when the Button control is clicked. This event is commonly used when no command name is associated with the Button control (for instance, with a Submit button). For more information about handling events, see Handling and Raising Events.

How do you handle button click events?

Onclick in XML layout When the user clicks a button, the Button object receives an on-click event. To make click event work add android:onClick attribute to the Button element in your XML layout. The value for this attribute must be the name of the method you want to call in response to a click event.

How do you call a button click event?

How can I call SubGraphButton_Click(object sender, RoutedEventArgs args) from another method? private void SubGraphButton_Click(object sender, RoutedEventArgs args) { } private void ChildNode_Click(object sender, RoutedEventArgs args) { // call SubGraphButton-Click(). }


2 Answers

I'm only familiar with ASP.net and C# buttons, but using C# you could wire two different buttons to the same click event handler. You could also do it client side by triggering the primary buttons click event with your secondary button. Here's a VERY simple example:

HTML

<input type="button" id="primaryButton" onclick="ExistingLogic()" /> <input type="button"         id="secondaryButton"         onclick="document.getElementById('primaryButton').click()" /> 
like image 86
James Hill Avatar answered Sep 27 '22 17:09

James Hill


<input type="button" id="primaryButton" onclick="ExistingLogic()" /> <input type="button" id="secondaryButton"/>  $('#secondaryButton').click(function(){     $("#primaryButton").click(); }) 
like image 37
Itisha-systematix Avatar answered Sep 27 '22 19:09

Itisha-systematix