/    Sign up×
Community /Pin to ProfileBookmark

button identification??

I have 3 buttons on the page and each has type of submit.So how we can identify on other page which one button is clicked??

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@mthorMar 11.2009 — just give the button a name or an id.

you need to be more clear not sure what all you are wanting?

Maybe post some code
Copy linkTweet thisAlerts:
@sawmasterMar 12.2009 — I think maybe he means for the server to know which button was pressed. I guess put a [code=html]name="NAME GOES HERE"[/code] in the input tag. NOTICE: You should use <input type=submit>. It sounds like your using <button>.
Copy linkTweet thisAlerts:
@wisemind85authorMar 12.2009 — Well the thing that i want is.

I have 3 buttons with ids b1,b2,b3

<form name='form1' action='abc.jsp'>

<input type='Submit' value='b1' id='b1'/>

<input type='Submit' value='b2' id='b2'/>

<input type='Submit' value='b3' id='b3'/>

</form>

So i want to get the value of button on jsp page using javascript that which one button was clicked,Do you think i have to define some hidden variable?? Any solution??
Copy linkTweet thisAlerts:
@ZeroKilledMar 12.2009 — the answer was already given, read post #3. simply put a name with a value on each submit button. when sent, JSP will have an entry for the submit and the value:

<input type='submit' name='send' value='edit' />

<input type='submit' name='send' value='save' />

<input type='submit' name='send' value='open' />

notice each button have the same name with different values. say if you press 'edit', a query is sent as 'send=edit'. of course, on server you have to read the value and do the necessary task according to value. as you can see, there is no need to involve javascript.
×

Success!

Help @wisemind85 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...