move data from one select to another through database. URGENT.
i have 2 select boxes.. on pressing a button i want to the item selected from select box1 to be entered into database and fire a query to find the most recent entry and retrieve it into the second select box2. kindly help me . i have no idea how to go about this. i did achieve this using javascript but then again was stuck as to how to use jdbc in javascript.
thanks in advance.
[393 byte] By [
reecha05a] at [2007-11-26 18:00:50]

# 3
May I know what frameworks are you using? (Ibatis, Struts, Spring.. ?)
I know how to do it using Ibatis and Struts 2. So you have 2 select (drop-down) fields and one submit button right? What you want to do is when you select an item from the first drop-down menu and press the submit button, you want to populate the second drop-down based on the item selected from the first drop down, right? Here's what you do. The first drop-down is populated already. When you press the Submit button, it goes to an action. In the action, get the value selected from the first drop-down menu, use the item seleced to make a query in the database, store the result in a List, and use that list to populate the second drop-down. Of course, the action should forward to the same page, so it can populate the second drop-down..
# 5
i am posting the code. i am doing the needed using javascript. now i need to do the same thing using jdbc..
<html>
<head>
<script type="text/javascript">
function selectUser(ss1,ss2)
{
var selId='';
var selText='';
for(i=ss1.options.length-1 ; i>=0; i--)
{
if (ss1.options[i].selected == true)
{
selId = ss1.options[i].value;
selText = ss1.options[i].text;
var newRow = new Option(selText,selId);
ss2.options[ss2.length] = newRow;
ss1.options[i] = null;
}
}
}
</script>
</head>
<body>
<form name="Example">
<table>
<tr>
<td>
<select name="memberList" size="5">
<option value="one">one</option>
<option value="two">two</option>
<option value="three">three</option>
<option value="four">four</option>
<option value="five">five</option>
</select>
</td>
<td>
<table>
<tr>
<input type="button" name="push" value="->" onClick="selectUser(document.Example.memberList,document.Example.loggedinList)">
</tr>
<tr>
<input type="button" name="pull" value="<-" onClick="selectUser(document.Example.loggedinList,document.Example.memberList)">
</tr>
</table>
</td>
<td>
<select name="loggedinList" size="5">
<option value="seven">seven</option>
</select>
</td>
</tr>
</table>
</form>
</body>
</html>
# 6
What ever you want to achieve is not difficult at all.
Inorder to accomplish what you need, you must have following things configured.
1). The html code you have posted should be first stored in a JSP file. Simple change extension of file from html to jsp.
2). In order to execute your JSP you need to have web server on your machine.
3). To store data to data base using jdbc, you need to have a database for e.g. oracle/DB2/MS access etc.
4). If you have database available with you, then you must have required tables in database.
Please check all above steps and let me know if you have an enviornment configured with you.
Regards,
Lave Kulshreshtha
Lavea at 2007-7-9 5:30:13 >
