×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

howto populate a select box using post data from a previous select box

howto populate a select box using post data from a previous select box

howto populate a select box using post data from a previous select box

(OP)
Hi all. What I'm trying to do is get the contents of a select control from a previous pages form and then populate a new select control using all the options in the previous one (using jsp)

Its for a life insurance calculator. The user puts in details of all previous eplans  they have in place. There may be more than one plan so they have the option to keep adding plans. Once this is done, they proceed to a summary page which display everything including all the existing plans.

What I want to know is how can I access all the options in a particular select control to output them? I've already set all the options to selected in the previous form. Is this what I need to do or is there some other way?

If I'm going about this the wrong way, can you suggest an alternative? Many thanks.

RE: howto populate a select box using post data from a previous select box

CODE

<html>
<head>
<script lang="JavaScript">
var count = 0;
function mystore(inpname){
var str = "document.f1."+inpname;
obj = eval(str);
if (obj.selectedIndex!=0)
   {
    if (count>0)
       {
        document.f1.secret.value+="_"
       }
    document.f1.secret.value+=obj[obj.selectedIndex].value;
    count++;
   }
}
function showAll()
 {
  alert(document.f1.secret.value);
 }
</script>
</head>
<body>
<form name="f1">
<input type="hidden" name="secret" value="">
<select name="sa">
<option value="">choice sa</option>
<option value="a001">plan a001</option>
<option value="a003">plan a003</option>
</select>
<input type="button" value="add to list" onClick="mystore('sa')">
<br>
<select name="sb">
<option value="">choice sb</option>
<option value="b002">plan b002</option>
<option value="b004">plan b004</option>
</select>
<input type="button" value="add to list" onClick="mystore('sb')">
<br>
<select name="sc">
<option value="">choice sc</option>
<option value="c001">plan c001</option>
<option value="c005">plan c005</option>
</select>
<input type="button" value="add to list" onClick="mystore('sc')">
<br>
<input type="button" value="submit form" onClick="showAll()">
</form>
</body>
</html>

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close