I want to see tab No. 2 when "IF Condition"开发者_如何转开发 will meet the requirements. Here is my code. Please advice me how can I do this.
Thanks Shahid
<?php
//Authorization / Security
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link type="text/css" href="../javascript/jquery/themes/ui-lightness/jquery.ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="../javascript/jquery/jquery-1.4.2.js"></script>
<script type="text/javascript" src="../javascript/jquery/ui/jquery.ui.core.js"></script>
<script type="text/javascript" src="../javascript/jquery/ui/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../javascript/jquery/ui/jquery.ui.tabs.js"></script>
<script type="text/javascript">
$(function() {
alert('main');
$("#container").tabs({
ajaxOptions: {
error: function(xhr, status, index, anchor) {
$(anchor.hash).html("Couldn't load this tab. We'll try to fix this as soon as possible. If this wouldn't be a demo.");
}
}
});
});
</script>
<?php
if($_GET['action'] == "add")
{
////////////////// Trigger Tab No. 2 ////////////////
///////////////// and ///////////////
//////////////// change url of Tab 3 ///////////////
}
?>
</head>
<body leftmargin="0" topmargin="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2"><?php include("../includes/headerone.php");?></td>
</tr>
<tr>
<td width="15%"><?php include("../includes/leftbar.php");?></td>
<td width="83%" ><div id="container">
<ul class="tabs-nav">
<li><a href="add.php"><span>Add</span></a></li>
<li><a href="edit.php"><span>Edit</span></a></li>
<li><a href="view.php"><span>View</span></a></li>
</ul>
</div></td>
</tr>
<tr>
<td colspan="2"><?php include("../includes/footer.php");?></td>
</tr>
</table>
</body>
</html>
Try your script tag like this, it adds javascript to do what you want by echoing it into the self calling anonymous function if the php condition is met
<script type="text/javascript">
$(function() {
alert('main');
$("#container").tabs({
ajaxOptions: {
error: function(xhr, status, index, anchor) {
$(anchor.hash).html("Couldn't load this tab. We'll try to fix this as soon as possible. If this wouldn't be a demo.");
}
}
});
<?php
if($_GET['action'] == "add"){
echo "$('.tabs-nav li a:eq(1)').trigger('click');";
echo "$('.tabs-nav li a:eq(2)').attr('href', 'newurl');";
}
?>
});
</script>
精彩评论