/    Sign up×
Community /Pin to ProfileBookmark

Submit FORM to SAME PAGE

For example if I have a normal form like this:

<form name=”form1″>
<input type=”text” name=”lName”>
<input type=”text” name=”fName”>

<input type=”button” Value=”Submit” onClick=”some javascript action”>
</form>

I want to display the inputs of both the textbox in the same page after clicking the button, for example, just below the form.

How do I do it? ?

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@TheBearMayJul 02.2008 — [code=html]
<form name="form1">
<input type="text" name="lName" id="lName" >
<input type="text" name="fName" id="fName">

<input type="button" Value="Submit" onclick="document.getElementById('oPut').innerHTML = 'Welcome '+document.getElementById('fName").value+' '+document.getElementById('lName").value>"
</form>
<div id="oPut"></div>
[/code]
Copy linkTweet thisAlerts:
@joyceqianauthorJul 02.2008 — if im using scripts like ASP / JSP. how retrieve those values so that i can process them? e.g if they re numbers?
Copy linkTweet thisAlerts:
@TheBearMayJul 02.2008 — By default the values will be sent to the POST header upon form submit, so just retrieve the values from there.
Copy linkTweet thisAlerts:
@joyceqianauthorJul 02.2008 — sorry, post header as in.. the query string?

if my form method is POST? how do i retrieve it? request.getParameter?
Copy linkTweet thisAlerts:
@TheBearMayJul 02.2008 — ASP: <%=Request.Form("fName")%>

JSP: <%=request.getParameter( "fName" )%>
Copy linkTweet thisAlerts:
@joyceqianauthorJul 03.2008 — Sorry, i still cannot get what i desire..

The form doesnt even post, the button:

<input type="button" Value="Submit" onclick="document.getElementById('oPut').innerHTML = 'This is '+document.getElementById('num1').value+'<br>This is '+document.getElementById('num2').value">

only prints what was input in the textbox and i cant seem to extract that value and convert to something that can be processed by JSP/ASP. ?
×

Success!

Help @joyceqian 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.10,
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,
)...