shaolex Posted July 10, 2006 Share Posted July 10, 2006 I have written a form for entering publications for a webpage. At the bottom of the form, there are a series of checkboxes which allow the user to select the author(s) from a list of faculty members. However, when the data is written into the database, the order of the authors corresponds to their keys in from the table of authors, not the order clicked on the webpage. This is a problem because the primary author/researcher is not being listed first. Is there anyway to preserve the clicking order when the form passes it as an array to the PHP script?Does any of this make sense?Thanks in advance to anyone who can offer some help and/or suggestions! Quote Link to comment https://forums.phpfreaks.com/topic/14185-how-can-i-record-the-order-of-clicked-checkboxes-in-phpmysql/ Share on other sites More sharing options...
designationlocutus Posted July 10, 2006 Share Posted July 10, 2006 Ooh a brainteaser. Sounds like a dynamic on static problem. I'd suggest using event handling in Javascript to create your sequence of numbers. They would be dynamically created on the static page when a user checks the box and placed in a hidden or disabled field on the form. Then when the form is submitted, the clicking order is preserved. Quote Link to comment https://forums.phpfreaks.com/topic/14185-how-can-i-record-the-order-of-clicked-checkboxes-in-phpmysql/#findComment-55598 Share on other sites More sharing options...
glenelkins Posted July 10, 2006 Share Posted July 10, 2006 HiYou could try an onClick event to trap the checkbox that is clicked.Example:[code]EXAMPLE.PHP<form name="form1" action="action.php" method="post"> <input type="checkbox" name="C1" value="Author1" onClick="location.href='checkclick.php?box=C1"> <input type="checkbox" name="C2" value="Author2" onClick="location.href='checkclick.php?box=C2'"></form>[/code][code]CHECKCLICK.PHP$clicked_box = $_GET['box'];$box_order_array[number] = $clicked_boxheader ("Location: example.php?box=$clicked_box");[/code]Obviously you will need code in the EXAMPLE.PHP to trap the return and put a check in the corresponding box. And you will probably need a global variable (to count the number of boxes clicked for the array in CHECKCLICK.PHP), unless you just use the same page (ie action="<? $_SERVER['PHP_SELF']; ?>")Or you could use JavaScript!Hope this kinda sheds some light Quote Link to comment https://forums.phpfreaks.com/topic/14185-how-can-i-record-the-order-of-clicked-checkboxes-in-phpmysql/#findComment-55600 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.