cesarhtown Posted May 1, 2006 Share Posted May 1, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/8838-php-arrays-and-javascript/ Share on other sites More sharing options...
Zane Posted May 1, 2006 Share Posted May 1, 2006 do want it to actually create an inline usuable array that you could use after the select boxor are you looking for the button to just create PHP code for you to copy and paste somewhere? Quote Link to comment https://forums.phpfreaks.com/topic/8838-php-arrays-and-javascript/#findComment-32438 Share on other sites More sharing options...
cesarhtown Posted May 1, 2006 Author Share Posted May 1, 2006 I would like to put my selections into an array called $names or something like that. I would like to have it in an array to manipulate the data somewhere else later on. Quote Link to comment https://forums.phpfreaks.com/topic/8838-php-arrays-and-javascript/#findComment-32444 Share on other sites More sharing options...
Zane Posted May 1, 2006 Share Posted May 1, 2006 I'm pretty sure this isn't possible in PHP, unless you refreshed the page when they pushed the buttonbut it could be done in AJAX, but you're array would be of Javascript rather than PHP Quote Link to comment https://forums.phpfreaks.com/topic/8838-php-arrays-and-javascript/#findComment-32446 Share on other sites More sharing options...
cesarhtown Posted May 1, 2006 Author Share Posted May 1, 2006 Ok, so lets assume that the page is refreshed. Now after clicking on the button, what is the procedure to put those selections in an array on Php? Quote Link to comment https://forums.phpfreaks.com/topic/8838-php-arrays-and-javascript/#findComment-32453 Share on other sites More sharing options...
Zane Posted May 1, 2006 Share Posted May 1, 2006 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 formset the form to POST or GET to the same pagethen at the top of you're page check for that POST or GET value and create an array from thatE.G[code]if(isset($_POST['names'])) $names = $_POST['names'];[/code] Quote Link to comment https://forums.phpfreaks.com/topic/8838-php-arrays-and-javascript/#findComment-32454 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.