[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

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

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
prashkul2
Asked:
prashkul2
1 Solution
 
aolXFTCommented:
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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now