Jump to content

PHP, Arrays, and Javascript


cesarhtown

Recommended Posts

Hello all. I need some help with some javascript using php.

*I have a list in a <select></select> with 5 different <option>'s.
**Now, I wish to select 1, 2, or more of those 5 options and have a button next to the box that says "CREATE ARRAY".
***When I click on CREATE ARRAY, I want to create a PHP array onclick, in other words storing those selections into an array. Any ideas?

Please help.

Cesar.
Link to comment
https://forums.phpfreaks.com/topic/8838-php-arrays-and-javascript/
Share on other sites

set the name of the selection box to an array like

<select name="names[]">
...
</select>

and put that along with your Create button in a form


set the form to POST or GET to the same page

then at the top of you're page check for that POST or GET value and create an array from that

E.G
[code]if(isset($_POST['names']))
   $names = $_POST['names'];
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.