Solved

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

Posted on 2001-08-03
8
175 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:cys050200
ID: 6347854
in java
0
 
LVL 22

Accepted Solution

by:
CJ_S earned 20 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
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).

707 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