Solved

passing the values from one select/list box to other select/list box at the submit

Posted on 2003-12-07
3
200 Views
Last Modified: 2006-11-17
I want to select the multiple values from the select box and would like to insert these values into another select box which is in the same page  and viceversa  at the click of submit , can anybody help me out in this.
0
Comment
Question by:prashkul2
[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 Comments
 
LVL 6

Accepted Solution

by:
aolXFT earned 125 total points
ID: 9891906
Do you want to do this client-side or serverside? I'll assume it is serverside since this is the PHP area, and PHP is a serverside language.

to get multible values from a select field, you simply add the word multiple into the tag.

Then when you are processing the form serverside next time around you check if the value exists in the array and if so check it.

Eg:

<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<select name="sel_name[]" multiple>
<option value="val_one" <?php if(in_array('val_one', $_POST['sel_name'])){ echo "checked"; } ?>>Value 1</option>
...
...
</select>
<input type="submit" value="Submit">
</form>


0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

732 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