php - Submit Form to action based on Selection -
i have list of records in table checkbox beside each one.
the user selects number of records ticking checkbox , selects action drop down list of links.
<div class="button-group"> <button type="button" id="but1">action</button> <ul class="dropdown" id="dropdown-but1"> <li><a href="#">update attendees</a></li> <li><a href="#">another action</a></li> <li><a href="#">one more action</a></li> </ul> </div>
an example of action might updating if user attend event.
if(isset($_post['submit'])) { foreach ($_post['checkbox_mark'] $value => $dummy) { $option = isset($_post['checkbox'][$value]) ? '1' : '0'; // send data model $eventregistrationmodel->markattended($value, $id, $option); } }
at minute have working single submit button, user able choose list of options in dropdown , appropriate action called.
i can't seem find example of this, maybe not searching correct term. assuming need use jquery this.
i have found way using form elements https://stackoverflow.com/a/17423522/1472203 wondering if possible text links.
then have many different submit buttons you'd each action , in action file check submission of buttons:
<div class="button-group"> <button type="button" id="but1">action</button> <ul class="dropdown" id="dropdown-but1"> <li><input type="submit" name="update_attendees" value="update attendees" class="buttonthatlookslikealink"></li> <li><input type="submit" name="another_action" value="another action" class="buttonthatlookslikealink"></li> <li><input type="submit" name="one_more_action" value="one more action" class="buttonthatlookslikealink"></li> </ul> </div>
then in php:
<?php if($_server["request_method"]==="post") { if(isset($_post["update_attendees"])) { # update attendees! } elseif(isset($_post["another_action"])) { # other action! } elseif(isset($_post["one_more_action"])) { # other action } }
Comments
Post a Comment