?
Solved

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

Posted on 2003-12-07
3
Medium Priority
?
202 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 500 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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

770 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