Hello there,
I've got this situation:
First
I've got a index.tpl who have a table contain 1 line merging two columns and two columns inserted independently. In the line I've put a header.tpl, at the first column I've put a login.tpl, and at the last column the register.tpl.
Second
I've got some dropdown menus into the register.tpl who needs to be filled with values from database.
So,
I wrote various scripts named select_role.php, select_jobpos.php, etc.. to generate the dynamic dropdown and substitute there into the register.tpl, so after that the index.php do the same but he substitute the commented block into the index.tpl
I am looking for someway to substitute a dynamic dropdown into the register.tpl without need to wrote a auxiliary script todo that for me. Anyone knows anything about how to do this?
My codes are below:
For index.php
CODE
<?
include_once './classes/template.class.php';
include_once './classes/imysql.class.inc';
$sql = new MySQL();
$sql->myConnect();
//create a new TemplatePower object using a file
$tpl = new TemplatePower( "./templates/index.tpl" );
//Define the header block
$tpl->assignInclude( "header", "./templates/header.tpl" );
//Define login blocks
$tpl->assignInclude( "login", "./templates/login.tpl" );
//Define registration blocks
$tpl->assignInclude( "register", "./templates/register.tpl" );
$tpl->prepare();
$tpl->printToScreen();
?>
For index.tpl
CODE
<html>
<head>
<title>Index</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="100%%" border="0">
<tr>
<td colspan="2">
<!-- INCLUDE BLOCK : header -->
</td>
</tr>
<tr>
<td>
<!-- INCLUDE BLOCK : login -->
</td>
<td>
<!-- INCLUDE BLOCK : register -->
</td>
</tr>
</table>
</body>
</html>
for register.tpl
CODE
<style media="screen" type="text/css">
#op2{visibility:hidden;}
#op3{visibility:hidden;}
</style>
<!-- To create the visability or not of the Manager and Team Leader' fields -->
<script language="javascript">
function Changeoption(v)
{
if (v.value == 0) {
document.getElementById('op2').style.visibility='hidden';
document.getElementById('op3').style.visibility='hidden';
}
if (v.value == 1){
document.getElementById('op2').style.visibility='hidden';
document.getElementById('op3').style.visibility='hidden';
}
if (v.value == 2){
document.getElementById('op2').style.visibility='hidden';
document.getElementById('op3').style.visibility='hidden';
}
if (v.value == 3){
document.getElementById('op3').style.visibility='hidden';
document.getElementById('op2').style.visibility='visible';
}
if (v.value == 4){
document.getElementById('op2').style.visibility='visible';
document.getElementById('op3').style.visibility='visible';
}
}
</script>
<form name="registered" method="post" action="register.php">
<table width="50%" border="0" align="center">
<tr>
<td class='style'><div align='right'>ROLE</div>
</td>
<td colspan='2'>
<!-- INCLUDESCRIPT BLOCK : ./select_role.php -->
</td>
</tr>
<div align="right">
<input type="submit" name="Submit2" value="Ok">
</div>
</table>
</form>
For select_role.php
CODE
<?php
require_once './classes/imysql.class.inc';
require_once './classes/template.class.php';
//Populate the select box with their needs
$sql = new MySQL();
$sql->myConnect();
$category = $sql->myExe("SELECT * FROM role");
print "<select name='Role_Id_FK' id='Role_Id_FK'>";
print "<option value='default'>- Choose -</option>>";
while($line = $sql->myFetcharray($category)) {
print "<option value='".$line['Role_Id_PK']."'>".$line['Role_Name']."</option>";
}
print "</select>";
?>
I will not write the others.
Anyone have any idea?
I am using template power class 3.0