javascript - html form two buttons with two actions -
hi there have got simple form work , both functionality update , delete working cannot seem figure out way make them work simultaneously in 1 form... here doing
<form id ='udassignment' method ='get' name='udassignment'> <input id ='action' type ='hidden' name ='action' value ='updatemessagefromsimpleform' /> <label for='fid'> id </label> <input id ="fid" type='number' name ='fid' readonly/> <label for='ftitle'> title </label> <input id ="ftitle" type='text' name ='ftitle'/> <label for='fmodule'> module </label> <input id ="fmodule" type ='text' name ='fmodule'/> <label for='fdescription'> description </label> <textarea rows ='4' id ='fdescription' type ='text' name ='fdescription'> </textarea> <label for='fduedate'> duedate </label> <input id ="fduedate" type='date' name ='fduedate'/> <div class ="form-group"> <div class ="controls"> <button type ="submit" class ="btn btn-primary"> update </button> <button type ="submit" class = btn btn-default"> delete </button> </div> </div> </form>
so @ moment action update set want know how set action delete fire if click delete button
you need add client-side code. ideally separate javascript function validation etc. @ simplest can modify delete button to:
<button type ="submit" class = "btn btn-default" onclick="document.getelementbyid('action').value = 'deletemessagefromsimpleform';" > delete </button>
before button submits - calls handler click event changes value of hidden field new action.
Comments
Post a Comment