I have 4 form in a HTML table,use 4 button to call the form out.
HTML:
<div id="myAccordion">
<table id="edit"
class="table table-striped table-bordered table-hover table-condensed table-nonfluid1 thumbnail">
<tbody>
<tr>
<td width=50%>
<button type="button" class="btn btn-info btn-lg" data-parent="#myAccordion"
id="cpass"
onclick="document.getElementById('col').style.display = 'inline'">form1
</button>
</td>
<td width=50%>
<button type="button" class="btn btn-primary btn-lg" data-parent="#myAccordion"
id="cinfo"
onclick="document.getElementById('col').style.display = 'inline'">form2
</button>
</td>
</tr>
<tr>
<td width=50%>
<button type="button" class="btn btn-info btn-lg" data-parent="#myAccordion"
id="cmail"
onclick="document.getElementById('col').style.display = 'inline'">form3
</button>
</td>
<td width=50%>
<button type="button" class="btn btn-primary btn-lg" data-parent="#myAccordion"
id="cplace"
onclick="document.getElementById('col').style.display = 'inline'">form4
</button>
</td>
<tr>
<td colspan="2" style="display:none;" id="col">
<div id="form1" class="collapse">
<form method="POST" action="updatepassc.php" novalidate="novalidate" id="1">
<div class="form-group">
<label for="oldpassword" class="control-label ">1:</label>
<input type="password" class="form-control" id="oldpassword"
name="oldpassword">
<span class="help-block"></span>
</div>
<div class="form-group">
<label for="newpassword" class="control-label ">2:</label>
<input type="password" class="form-control" id="newpassword"
name="newpassword">
<span class="help-block"></span>
</div>
<div class="form-group">
<label for="newpassword1" class="control-label ">3:</label>
<input type="password" class="form-control" id="newpassword1"
name="newpassword1">
<span class="help-block"></span>
</div>
<button type="submit" class="btn btn-success btn-block">yes</button>
</form>
</div>
<div id="form2" class="collapse">
.
<form method="POST" action="updateinfo.php" novalidate="novalidate">
<div class="form-group">
<label for="newinfo" class="control-label ">2</label>
<textarea class="form-control" rows="3" id="newinfo"
name="newinfo">></textarea>
<span class="help-block"></span>
</div>
<button type="submit" class="btn btn-success btn-block">yes</button>
</form>
</div>
<div id="form3" class="collapse">
.
<form method="POST" action="updateinfo.php" novalidate="novalidate">
<div class="form-group">
<label for="newinfo" class="control-label ">3</label>
<textarea class="form-control" rows="3" id="newinfo"
name="newinfo">></textarea>
<span class="help-block"></span>
</div>
<button type="submit" class="btn btn-success btn-block">3</button>
</form>
</div>
<div id="form4" class="collapse">
.
<form method="POST" action="updateinfo.php" novalidate="novalidate">
<div class="form-group">
<label for="newinfo" class="control-label ">4</label>
<textarea class="form-control" rows="3" id="newinfo"
name="newinfo"></textarea>
<span class="help-block"></span>
</div>
<button type="submit" class="btn btn-success btn-block">yes</button>
</form>
</div>
</td>
</tr>
</tbody>
</table>
</div>
And i want to show different form in (td id="col"),but it have a error , it will show two form in same time.I want if i click a button,1 form will open , anther form will close.For example,if form 1 open,form 2,3,4 will close
This is the javascript code:
<script type="text/javascript">
$(document).ready(function () {
$('#cpass').click(function () {
$('#form1').collapse('show');
if ($('#form2').is(':visible'))
$('#form2').collapse('hide');
});
$('#cinfo').click(function () {
$('#form2').collapse('show');
if ($('#form1').is(':visible'))
$('#form1').collapse('hide');
});
$('#cmail').click(function () {
$('#form3').collapse('show');
if ($('#form4').is(':visible'))
$('#form4').collapse('hide');
});
$('#cplace').click(function () {
$('#form4').collapse('show');
if ($('#form3').is(':visible'))
$('#form3').collapse('hide');
});
});
The jsfiddle
How can i fix the problem?