Solved

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

Posted on 2001-08-03
8
168 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
  • 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

839 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