|
Hi, I'm a beginner at java, still learning, so have some patience with me :) I have this .java page which should get and set a HtmlPage, and this HtmlPage has a drop down list with values(I use firebug in Mozilla firefox to inspect this element), and this code is what appears in the firebug inspection window:
[code]<select id="instance2" name="instance2">
<option value="0">All instances</option>
<option value="1">Item0</option>
<option value="2">Item1</option>
<option value="3">Item2</option>
.
.
.
<option value="23">Item22</option> [/code]
What I want to do is actually to get the value that a user has selected from the drop down list, and save it to the database, and someone told me I could use getElementById(), and I have this code that I found on the internet:
[code]<select name="mySelect" id="mySelect" onchange="getSelectedValue();">
<option value="1">Text 1</option>
<option value="2">Text 2</option>
</select>
<script type="text/javascript">
function getSelectedValue() {
var index = document.getElementById('mySelect').selectedIndex;
alert("value="+document.getElementById('mySelect').value);
alert("text="+document.getElementById('mySelect').options[index].text);
}
</script> [/code]
I really need help here because it's urgent, and I've been to many other forums, but there are people telling me that it's I should go either java or javascript forums. Please tell me if I'm at the right forum and if not, which one I should go to.
Thanks, any help is greatly appreciated :)
|
|
|
|
|
|
|
|