Vincent Kong
Vincent Kong

Reputation: 23

Multiple "OnSubmit" in Form

On the current website I am working on we have a Html Form that wraps everything and is used by the global search to submit and search when the user presses enter in the "global search" text box.

The problem we are now having is that we have a application form which has its own text boxes within this Html Form and when you press enter it does a onSubmit for the Global Search.

So in short I was wondering if there was any way to change certain specific text boxes to do a different onSubmit than the global search.

Many Thanks,
Vincent Kong

Upvotes: 0

Views: 172

Answers (3)

GalacticCowboy
GalacticCowboy

Reputation: 11759

Although this quickly becomes messy, you can set the CommandName attributes on each of your buttons and handle them appropriately (based on the command value of the clicked button) during the postback.

Upvotes: 0

Nick
Nick

Reputation: 3337

Instead of using type="submit" buttons use regular buttons (type="button") then call javascript to do what you want.

Upvotes: 1

user2216267
user2216267

Reputation: 491

you can use HTML5 formaction Attribute:

<form action="demo_form.asp">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  <input type="submit" value="Submit"><br>
  <input type="submit" formaction="demo_admin.asp" value="Submit as admin">
</form>

Upvotes: 0

Related Questions