/    Sign up×
Community /Pin to ProfileBookmark

HTML input with multiple names/functions?

Hi, I’m looking for a way to have a single input button carry out multiple JS functions.

My variable, item_1, gets sent through the form with this code:

[code=html]<input type=”image” src=”add1.png” name=”item_1″/>[/code]

But item_1 is dynamically generated depending on how many records match the set, so there may be item_1 through item_26, and I want the input to send all 26 through.

I could have 26 different input buttons, but that would look awful. Is there a way to have one button execute them all?

TIA.

to post a comment
HTML

3 Comments(s)

Copy linkTweet thisAlerts:
@NoEffinWayFeb 24.2012 — make a hidden form that is populated like

item_1|item_2|item_3

and so on. Then you can pass the content of the hidden field to whereever and split the string by '|'
Copy linkTweet thisAlerts:
@clipper103authorFeb 28.2012 — Thanks for the quick reply.

I'm not sure what the correct syntax is here. I've tried the following three variations and the form loses functionality.

[code=html]<input type="image" src="add1.png" name="item_1" />
<input type="hidden" name="item_2"|"item_3"|"item_4"|"item_5" />
[/code]

[code=html]<input type="image" src="add1.png" name="item_1" />
<input type="hidden" name="item_2"|name="item_3"|name="item_4"|name="item_5" />[/code]


[code=html]<input type="image" src="add1.png" name="item_1" />
<input type="hidden" name="item_2" />
<input type="hidden" name="item_3" />
<input type="hidden" name="item_4" />
<input type="hidden" name="item_5" />[/code]


As it is, it executes the first item. While I try to add the additional items, it doesn't even do that.
Copy linkTweet thisAlerts:
@NoEffinWayFeb 28.2012 — Would be more like:
[CODE]<input type="image" src="add1.png" name="item_1"/>
<input type="image" src="add1.png" name="item_2"/>
<input type="image" src="add1.png" name="item_3"/>
<input type="image" src="add1.png" name="item_4"/>
<input type="hidden" name="passthisdata" value="item_1|item_2|item_3|item_4" />[/CODE]

What is the JS you want it to run? I didnt think to ask that before.
×

Success!

Help @clipper103 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.4,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...