/    Sign up×
Community /Pin to ProfileBookmark

general question

hey guys…

is a posible to get a variable from <input> without beeing in <form>?

my situation is:
a have a <form> but there i have a multiple rows (as im selection records from sql), so it may look like this:

[code=php]<form>
<input type=text name=name1[]><input type=text name=name2[]> – <input type=submit onclick=”xxxxxxxxx”>
<input type=text name=name1[]><input type=text name=name2[]> – <input type=submit onclick=”xxxxxxxxx”>
<input type=text name=name1[]><input type=text name=name2[]> – <input type=submit onclick=”xxxxxxxxx”>
<input type=text name=name1[]><input type=text name=name2[]> – <input type=submit onclick=”xxxxxxxxx”>
<input type=text name=name1[]><input type=text name=name2[]> – <input type=submit onclick=”xxxxxxxxx”>

<input type=submit>
</form>[/code]

so what i would say easiest way to make this works is to set each submit button to onclick to have like this:

[CODE]onclick=”window.location.href=’abc.php?name1=’+bla+’&name2=’+name2″[/CODE]

just this doesnt work ?…

guys please if u have any idea how to make this works, would be awesome ?

EDIT: the thing is to make submit all by one master submit button, but also need to submit each row separatelly…. if you have any other idea how to do that then im open for ideas…. as far as you cant nest forms html than the window.location on onclick sounds as a best idea to do that

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@KorOct 25.2009 — You may group the inputs in DIVs, and use a somple button, not a submit one
<i>
</i>&lt;div&gt;
&lt;input type="text" name="name1[]"&gt;&lt;input type="text" name="name2[]"&gt; - &lt;input type="button" onclick="submitThis(this)"&gt;
&lt;/div&gt;

And the function could be something like that
<i>
</i>function submitThis(but){
var fld=but.parentNode.getElementsByTagName('input');
var frm=but.form;
frm.action='abc.php?'+fld[0].name+'='+fld[0].value+'&amp;'+fld[1].name+'='+fld[1].value;
frm.submit();
}
×

Success!

Help @Shokarta 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.18,
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,
)...