Hi, My goal is to create a tabbed document. The information to be used in the content <div>'s comes from a MySql database. Here is the html and js code I've used.
1. The base html to create the tab code. Code is in progress until I can get the data problem solved. (I'm hoping this isn't some embarrassing simple problem to solve !!!!)
2. The html code necessary to call the functions to provide the data from
MySql database.
Since URL's can't get info from functions, this is the problem..
3. The functions in a .js file that actually get the data.
When I use 2. to call the functions the data returned will only show up in that page. Therefore, page 1. will never get the content to show in the tabs.
See comments in html's for problem area.
1. =============
sagleTableData.html ===========================
Code:
<!DOCTYPE HTML >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>sagleTableData.html-Jan2014</title>
<!-- ================= scripts ==================-->
<script src="../jquery/jquery-1.9.1.js"></script>
<script src="sagle-tabs.js"></script>
</head>
<body>
<p><h2>This is trial coding to create tabs for codes that comprise Sagle Improvements. Data in MySql 'sagle' database.</h2></p>
<div style="width:300px;">
<!-- FORM NOT USED - Testing Only
<form method="get" action="#">
<fieldset>
<legend>Pick a Category.</legend>
<input type="button" size="30" id="workcodes" onclick='getCode("workcodes")' size="35" >Work Codes<br />
<input type="button" size="30" id="projects" onclick='getCode("projects")' size="35" />Projects<br />
<input type="button" size="30" id="vendors" onclick='getCode("vendors")' size="35" />Vendors<br />
</fieldset>
</form>
-->
<div id="tabset">
<ul>
<li><a href="sagleShowCodes.html?table=workcodes" >TabWork</a></li>
<li><a href="sagleShowCodes.html?table=projects" >TabProj</a></li>
<li><a href="sagleShowCodes.html?table=vendors" >TabVend</a></li>
</ul>
</div>
</div>
<div id="wbox"> </div> <!-- PROBLEM AREA - Can't get data back here -->
<div id="pbox"> </div> <!-- These <div>'s will be converted to -->
<div id="vbox"> </div> <!-- proper content <div>'s when data problem can be solved and data brought here -->
</script>
</body>
</html>
2. =============
sagleShowCodes.html =========================
Code:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>sagleShowCodes.html-Jan2014</title>
<!-- ================= scripts ==================-->
<script src="../jquery/jquery-1.9.1.js"></script>
<script src="../jquery/getHtmlParams.js"></script>
<script src="sagle-tabs.js"></script>
</head>
<body>
<script type="text/javascript">
var myCode = getUrlParametersVals()["table"];
getCode(myCode);
</script>
<div id="wbox"> </div> <!-- I've put these <div>'s here only to see -->
<div id="pbox"> </div> <!-- the data returned from the function call -->
<div id="vbox"> </div> <!-- It is data destined for the content of the Tabs -->
</body>
</html>
3. =============
sagle-Tabs.js ==============================
Code:
// ========== getCode() =============
function getCode(x) {
switch(x) {
case "workcodes":
showWorkCodes(x);
break;
case "projects":
showProjects(x);
break;
case "vendors":
showVendors(x);
break;
default:
alert("doesn't work");
}
}
// ========== showWorkCodes() =============
function showWorkCodes(table) {
$.getJSON('sagleTableData.php?tbl='+table, function(invData) {
content="<table class='center' id='invTbl' border='3' cellpadding='5' bgcolor='#fedde3'> \n"
+"<caption><big><b>Work Codes</b></big></caption>"
+"<tbody><tr> <th class='headId' >Code Id</th> <th class='headId' >Description</th></tr> \n"
$.each(invData, function(key, val) {
content+="<tr><td>"+val.codeid+"</td><td>"+val.code+"</td></tr>";
});
content+="</tbody></table>";
$("#wbox").empty();
$("#pbox").empty();
$("#vbox").empty();
$(content).appendTo("#wbox");
}); // getJSON
};
// code for Projects and Vendors - similar