Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how to get the value in 'option' and assigned to a String in jsp?

Posted on 2001-08-03
8
Medium Priority
?
189 Views
Last Modified: 2010-04-09
i am writing a jsp file.

if i have a 'option' in html, how do i get the value of this 'option' and assigned it to a String in java?

<form>
<select name="select3">
<option value="01" selected>1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
</select>
</form>




0
Comment
Question by:cys050200
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 22

Expert Comment

by:CJ_S
ID: 6347812
in java or javascript?

<script>
var myvar = "";
</script>

<form>
<select name="select3" onChange="myvar=this[this.selectedIndex].value">
<option value="01" selected>1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
</select>
</form>


Now the selected value will be in the variable myvar.

regards,
CJ





0
 

Author Comment

by:cys050200
ID: 6347820
in java
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6347833
20 points for such a thing is very little!

Create a public method in your java applet:

public void addValue(int myval)
{
  ...assign variable here...
}

Once compiled I assume you give the APPLET tag the id and / or name "myapp1"

<form>
<select name="select3" onChange="document.myapp1.addValue(this[this.selectedIndex].value)">
<option value="01" selected>1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
</select>
</form>


Please note that this will NOT work in IE5 on the macintosh.

regards,
CJ
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:cys050200
ID: 6347854
in java
0
 
LVL 22

Accepted Solution

by:
CJ_S earned 80 total points
ID: 6347872
20 points for such a thing is very little!

Create a public method in your java applet:

public void addValue(int myval)
{
  ...assign variable here...
}

Once compiled I assume you give the APPLET tag the id and / or name "myapp1"

<form>
<select name="select3" onChange="document.myapp1.addValue(this[this.selectedIndex].value)">
<option value="01" selected>1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
</select>
</form>


Please note that this will NOT work in IE5 on the macintosh.

regards,
CJ
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6629469
You earned the 20 points CJ.  Make it an answer.

Cd&
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 6640854
It is time to clean this abandoned question up.  

I am putting it on a clean up list for CS.

<recommendation>
points to CJ_S

</recommendation>

If anyone participating in the Q disagrees with the recommendation,
please leave a comment for the mods.

Cd&
0
 

Expert Comment

by:ComTech
ID: 6686980
Answer accepted by:

ComTech
Community Support Moderator

Thanks COBOLdinosaur for your help.
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question