azraelGG Posted December 12, 2012 Share Posted December 12, 2012 so i use jquery script asmSelect for something now i stuck at 2 things 1. how do i hide that select field 2. how do i get all variables in array - i need to serialize array after heres the code (part of the code i use more input fileds and some selects for ful form have another button for sending all to sql) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="jquery.ui.js"></script> <script type="text/javascript" src="../jquery.asmselect.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#cestice").asmSelect({ animate: true, highlight: true, sortable: true }); $("#add_cestice_btn").click(function() { var cestice = $("#add_cestice").val(); var $option = $("<option></option>").text(cestice).attr("selected", true); $("#cestice").append($option).change(); $("#add_cestice").val(''); return false; }); }); </script> <link rel="stylesheet" type="text/css" href="../jquery.asmselect.css" /> </head> <body> <?php if(!empty($_POST['submit'])) { if(!empty($_POST['cestice'])) { foreach($_POST['cestice'] as $cestica) { // exclude any items with chars we don't want, just in case someone is playing if(!preg_match('/^[-A-Z0-9\., ]+$/iD', $cestica)) continue; // print the city echo "\n\t<li>" . htmlspecialchars($cestica) . "</li>"; } echo "\n</ul>"; } else { echo "\n<p>No items selected</p>"; } } ?> <form action="" method="post"> <p style="hidden"> <select id="cestice" multiple="multiple" name="cestice[]" style="display: hidden"> </select> </p> <p><em>You may click and drag cities to order of preference.</em></p> </form> <p> <label for="add_cestice">Dodaj česticu</label> <input type="text" id="add_cestice" value="" /> <button type="button" id="add_cestice_btn" href="#">Dodaj</button> </p> </body> </html> Link to comment https://forums.phpfreaks.com/topic/271902-modify-asmselect-and-get-variables/ Share on other sites More sharing options...
mrMarcus Posted December 12, 2012 Share Posted December 12, 2012 1. how do i hide that select field "hidden" is not a valid value of the display property. Use "none": <select id="cestice" multiple="multiple" name="cestice[]" style="display:none"> 2. how do i get all variables in array Variables is not the word you're looking for here. Since you have failed to explain what your code does, I have taken a look and it appears that users are entering data via an input box which then populates the select/options box? That's as much guessing as I will do. Please clarify your questions and what your script does. Link to comment https://forums.phpfreaks.com/topic/271902-modify-asmselect-and-get-variables/#findComment-1398894 Share on other sites More sharing options...
azraelGG Posted December 12, 2012 Author Share Posted December 12, 2012 hm... i can set paragraph to display none and then it hides, but wont show entries when i press add button if i set select on display none nothing happens script put that entry inside of select as option but what i need to do is modify that and use only input part with list of entries (with remove), and get entries (that are not removed) as array so i can serialize it and store it to database PS if you know any other js plugin/script that can do job feel free to suggest this is first thing i found that can input (unlimited) entries Link to comment https://forums.phpfreaks.com/topic/271902-modify-asmselect-and-get-variables/#findComment-1398895 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.