Solved

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

Posted on 2001-08-03
8
157 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
 

Author Comment

by:cys050200
ID: 6347854
in java
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article discusses how to create an extensible mechanism for linked drop downs.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
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)

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now