Here is my form:
<form method= "post" action= "edit.php">
<div class="panel-body">
<div class="row">
<div class="col-md-3 col-lg-3 " id= "show"> <img alt="User Pic" src="http://babyinfoforyou.com/wp-content/uploads/2014/10/avatar-300x300.png" class="img-circle img-responsive">
<a data-original-title="Upload Image" data-toggle="tooltip" type="button" class="btn btn-sm btn-info"><i class="glyphicon glyphicon-edit"></i></a>
</div>
<div class=" col-md-9 col-lg-9 ">
<table class="table table-user-information">
<tbody>
<tr>
<td>Name:</td>
<td><span id= "keep"><?php echo $firstname; ?></span><input id= "change" value= "<?php echo $firstname; ?>" style= "display:none;" name="name"></td>
</tr>
<tr>
<td>Date of Birth</td>
<td><span id= "keep1"><?php echo $birthday; ?></span><input id= "change1" value= "<?php echo $birthday; ?>" style= "display:none;" name="bday"></td>
</tr>
<tr>
<tr>
<td>Gender</td>
<td><span id= "keep2"><?php echo $gender; ?></span><input id= "change2" value= "<?php echo $gender; ?>" style= "display:none;" name="gen"></td>
</tr>
<tr>
<td>Country</td>
<td><span id= "keep3">US</span><input id= "change3" value= "US" style= "display:none;" name="country"></td>
</tr>
<tr>
<td>Email</td>
<td><span id= "keep4"><a href="mailto:info@support.com"><?php echo $email; ?></a></span><input id= "change4" value= "<?php echo $email; ?>" style= "display:none;" name="mail"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="panel-footer">
<a data-original-title="Broadcast Message" data-toggle="tooltip" type="button" class="btn btn-sm btn-primary"><i class="glyphicon glyphicon-envelope"></i></a>
<span class="pull-right">
<a href="#" data-original-title="Edit this user" data-toggle="tooltip" type="button" class="btn btn-sm btn-warning" onclick = 'showMe()'><i class="glyphicon glyphicon-edit"></i></a>
<a data-original-title="Save this user" data-toggle="tooltip" class="btn btn-sm btn-success" type="submit"><i class="glyphicon glyphicon-saved"></i></a>
</span>
</div>
</form>
How can I make only the "save" button go to edit.php not the others? Now when I click on it doesn't go anywhere, Then on edit. php I want it to update and return to this page with the updated version, I'm just stuck on how to get it to go to edit.php
Regarding form submission:
An HTML button will submit its parent form
if it is type="submit"
or has no type
attribute (it defaults to submit
).
An HTML button will not submit its parent form
if it is type="button"
.
<a>
tag rather than an <input>
or <button>
tag to submit your form, see: Submit form using <a> tag. But this solution is not recommended and is fairly bad practice if there's no reason to not use an <input>
or <button>
tag, since JavaScript does not work across all browsers, is disabled by default in others, and can always be disabled by users, in all cases rendering your form useless.Regarding the rest of your question:
Please add submit button to your form.
<input type="submit" name="submit-btn" class="btn btn-primary">
you need add the submit botton.
<button type="submit" class="btn >SAVE</button>
Give an id
for your form
<form id="myform" method= "post" action= "edit.php">
Now add this javascript to your anchor tag
onclick="document.getElementById('myform').submit();"
Now your anchor tag will look like
<a onclick="document.getElementById('myform').submit();"
data-original-title="Save this user" data-toggle="tooltip"
class="btn btn-sm btn-success"><i class="glyphicon glyphicon-saved">
</i></a>