/    Sign up×
Community /Pin to ProfileBookmark

how to store values from a listbox so you can use them in java-code

hi everybody!

as i have only little idea about javascript but i have to use it, here is my question:

i have a java servlet with a listbox. what i want to do is taking the selected values an put them into some variable so that i can use them within my java-code.

is that possible? i think it should be, but i dont know how.

thanks in advance for your help,
johanna

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@JohannaMosauthorOct 15.2004 — does no one know how to solve this problem?
Copy linkTweet thisAlerts:
@vwphillipsOct 15.2004 — cant give you a clear answer but as you haven't any other inputs

text can be transfered between java & javascript

so this may be possible,

if the variable values were incoded in the text they could be decoded into variables after tranfer
Copy linkTweet thisAlerts:
@xymarkdOct 15.2004 — When you submit the form, the HTML controls that have names will be passed as parameters, just as if you'd written them as URL parameters. For instance, if you have

<input type="text" name="tbox">

and type into the text box "textstring", that will be submitted to the target page as "&tbox=textstring" (no quotes around it). You can use the usual request.getParameter("tbox") call to fetch that value.

If you want a value you've calculated in JavaScript, not entered via a control, create an input control of type="hidden" and store the value in it.

I hope this helps.
Copy linkTweet thisAlerts:
@JohannaMosauthorOct 18.2004 — Thanks for your answers and sorry for my bad description.

I'll try again:

In one servlet there is the listbox where you can choose a value. In the java-code of this servlet I try to take the selected value and work with it. So I need the value before I submit the page.

I thought it would work with something like onchange. I know that you can submit the servlet with onchange=this.form.submit(). Do I have to use this and call the servlet again to use the values (with request.getParameter("theValue")) or is there a possibility to use the values instantly?

Thanks in advance, Johanna
Copy linkTweet thisAlerts:
@xymarkdOct 19.2004 — The list box is executing in your browser. The servlet is executing on your server (wherever your Tomcat or other server is running). As far as I know, the only way to get any data from your browser to your servlet is to submit it.

You can manipulate the data within the browser with JavaScript, but it still is limited to the browser.
×

Success!

Help @JohannaMos 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.19,
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,
)...