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
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.