php - Reference a hidden value in a form using jQuery/JavaScript -
i new web development
i have php delete function want use delete rows database table.
if($form_no==="delete" && isset($_post['id']) && isset($_post['form_no'])) { switch ($_post['form_no']) { case 1:$table="employees"; break; default:break; } $query="delete ".$table." id=".$_post['id']; mysql_query($query)or die( ' '.mysql_error().' '.$query); $message='deleted'; switch ($_post['form_no']) { case 1:manageemployees($message);break; default:break; } }
here 1 of forms displaying on screen
<tr><th>first name</th><th>last name</th><th>email</th><th>password</th><th>phone number</th></tr> <tr><td><input type="hidden" id="form_no" name="form_no" value="1"></td></tr> <tr><td><input type="text" name="firstname[]" id="firstname"></td> <td><input type="text" name="lastname[]" id="lastname"></td> <td><input type="text" name="email[]" id="email"></td> <td><input type="text" name="password[]" id="password"></td> <td><input type="text" name="phone_no[]" id="phone_no"></td> <td><button type="submit" name="submit" id="submit">add employee</button></td> <td><button type="button" name="delete" class="delete" value=21>delete employee</button></td></tr> <td><p><p></td> </tr>
i trying access other values in form. when button clicked can id looking value of button. want value of hidden field , find out in delete button pressed.
i can not use find elementbyid delete buttons not unique nor forms. trying use $(this).parents().parents('#form_no').val()
, returns undefined.
i know must possible not getting closer, many in advance if 1 can point me in right direction.
Comments
Post a Comment