?
Solved

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

Posted on 2001-08-03
8
Medium Priority
?
182 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

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

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

752 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