Tuesday, September 22, 2015

How to hide/show an element using jQuery

Change the display values onclick open & close button using JavaScript in PHP:-

<head>
<script src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
function chngsttsclose()
{
$("#close").show();
$("#open").hide();
}
function chngsttsopen()
{
$("#close").hide();
$("#open").show();
}
</script>
</head>

<style>
.iconButton
{
    font-size: 1em;
    color: transparent; /* Fix for Firefox */
    border-style: none;
    border-width: 0;
    padding: 0 0 0 16px !important; /* Fix for Internet Explorer */
    text-align: left;
    width: 25px;
    height: 20px;
    line-height: 1 !important;
    overflow: hidden;
    cursor: pointer;
}
</style>

<body>
<table>
<tr>
<td>
<input type="submit" class='iconButton' style='background:url(images/open.png) no-repeat' id="open" onclick="chngsttsclose(this.value)" name="packstus" />
<input type="submit" class='iconButton' style='background:url(images/close.png) no-repeat; display:none;' id="close" onclick="chngsttsopen(this.value)" name="packstus" />
 </td>
 </tr>
 </table>
</body>


How to add Delete button confirmation?

Here is the code:-

<body>
<form name="abc" action="test.php" method="post">
<input name="Cancel_Booking" onclick="return confirm('Are You Sure?');" value="Cancel Booking" style="background:transparent; color:#0066FF; border:none; cursor:pointer; font-size:14px; font-weight:bold;font-family:font-weight:bold;font-family:Cambria, 'Hoefler Text', 'Liberation Serif', Times, 'Times New Roman', serif" type="submit" />
</form>
</body>