Results 1 to 1 of 1
Related
-
Passing Javascript variables to a form Forum: Javascript Forum
Replies: 0 -
passing values of 3 variables from one php script to another Forum: PHP Forum
Replies: 2 -
Problem In Passing Variables Forum: PHP Forum
Replies: 2 -
call external Javascript(PHP) with passing value Forum: Javascript Forum
Replies: 2 -
Passing variables from HTML page to page Forum: HTML Forum
Replies: 1
-
09-13-2011, 11:54 AM #1
Passing variables to external PHP Javascript page
I am trying to pass the variables from the staff.php to the employeeNames.php (which is really an external javascript file).
Here is the code for the staff.php, if you scroll down to line 187 you will see an onclick to the external function.
All the dynamic data is working, I just can't figure out how to pass the bioId values from the staff page to the employees page. I am about to pull my hair out. Any help is great appreciated.
Code:<?php require_once('Connections/accessbhs.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_accessbhs, $accessbhs); $query_rsEmployees = "SELECT * FROM staffbio ORDER BY bioLastName ASC"; $rsEmployees = mysql_query($query_rsEmployees, $accessbhs) or die(mysql_error()); $row_rsEmployees = mysql_fetch_assoc($rsEmployees); $totalRows_rsEmployees = mysql_num_rows($rsEmployees); mysql_select_db($database_accessbhs, $accessbhs); $query_rsDirectory = "SELECT bioId, bioFirstName, bioLastName, bioTitle FROM staffbio ORDER BY bioLastName ASC"; $rsDirectory = mysql_query($query_rsDirectory, $accessbhs) or die(mysql_error()); $row_rsDirectory = mysql_fetch_assoc($rsDirectory); $totalRows_rsDirectory = mysql_num_rows($rsDirectory); mysql_select_db($database_accessbhs, $accessbhs); $query_rsBioStuff = "SELECT * FROM staffbio"; $rsBioStuff = mysql_query($query_rsBioStuff, $accessbhs) or die(mysql_error()); $row_rsBioStuff = mysql_fetch_assoc($rsBioStuff); $totalRows_rsBioStuff = mysql_num_rows($rsBioStuff); ?> <!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"> <?php /* php variables */ $pageTitle = "staff"; ?> <head> <script language="JavaScript" src="jscripts/employeeNames.php" type="text/javascript"> </script> <script language="JavaScript" type="text/javascript"> //function to capture the last clicked link so display can be set to none when another link is clicked var previousPage = "intro"; </script> <title>Access Behavioral Health - Our Staff</title> <link href="styles/accessbhs.css" rel="stylesheet" type="text/css" /> <style type="text/css"> #staffHomepage { float: right; width: 935px; border-left: #666701 2px dashed; border-right: #666701 2px dashed; border-top: #666701 2px solid; border-bottom: #666701 2px solid; margin: -100px 10px 0 10px; padding: 0 0 0 0; background-color: #FFFFE8; } #bioFooter { clear:both; font-family:Verdana, Geneva, sans-serif; font-size: 1em; color: #FFFFE8; text-align: center; margin: 30px 0 0 0; padding: 0 0 15px 0; } #staffDirectory { width: 200px; float: left; padding:0 50px 0 0; margin: 0 0 0 -25px; } #staffDirectory ul li { list-style-type: none; text-decoration:none; display:block; margin: 0 0 0 0; Padding: 0 0 0 0; } #staffDirectory ul li a:link { text-decoration: none; display:block; margin: 0 0 0 0; Padding: 0 0 0 0; } #staffDirectory ul li a:visited { text-decoration:none; display:block; margin: 0 0 0 0; padding: 0 0 0 0; } #staffDirectory ul li a:hover { text-decoration:none; display:block; margin: 0 0 0 0; Padding: 0 0 0 0; } #bioContentArea { background-color: #FFFFE8; padding: 0 0 0 0; margin: 37px 0 0 0; font-family:Verdana, Geneva, sans-serif; font-size:1em; } <?php do { ?> #_<?php echo $row_rsEmployees['bioId'];?> { display:none; float: right; width: 690px; margin: 0px 10px 10px 0px; padding:0 0 0 -220px; } <?php } while ($row_rsEmployees = mysql_fetch_assoc($rsEmployees)); ?> #intro { float: right; width: 690px; margin: 0px 10px 10px 0px; padding:0 0 0 -220px; } </style> </head> <body> <div id="wrapper"> <?php include("_includes/header.php"); ?> <?php include("_includes/menu.php"); ?> <div id="bioContentArea"> <div id="roundedTop"> <img src="images/contentHeader.gif" /> </div> <div class="photo"> </div> <div class="paperclip"><img src="images/paperClip.gif" alt="paperclip" /></div> <div id="staffHomepage"> <div id="staffDirectory"> <ul> <?php do { ?> <li><a href="#" onclick="switchUp('_<?php echo $row_rsDirectory['bioId']; ?>\', previousPage)"><?php echo $row_rsDirectory['bioLastName']; ?>, <?php echo $row_rsDirectory['bioFirstName']; ?></a><?php echo $row_rsDirectory['bioTitle']; ?><br /><br /></li> <?php } while ($row_rsDirectory = mysql_fetch_assoc($rsDirectory)); ?> </ul> </div> <noscript> You must enable Javascript to view! </noscript> <!-- end of serviceHomepage box --> <div id="intro"> <p> <h1>Our Employees</h1> <p>They are just normal people who don't have a clue.</p> </p> </div> <?php do { ?> <div id="_<?php echo $row_rsBioStuff['bioId'];?>"> <p> <h1><?php echo $row_rsBioStuff['bioFirstName']; ?> <?php echo $row_rsBioStuff['bioLastName']; ?> [<?php echo $row_rsBioStuff['bioTitle'];?>]</h1> <p> <?php echo $row_rsBioStuff['bioDescription'];?></p> </p> </div> <?php } while ($row_rsBioStuff = mysql_fetch_assoc($rsBioStuff)); ?> </div> <!-- end of homepage box --> <!--</div>--> <!-- end of content area --> <div id="bioFooter"> </div> </div> <!-- end of wrapper--> <?php include("_includes/footer.php"); ?> </body> </html> <?php mysql_free_result($rsEmployees); mysql_free_result($rsDirectory); mysql_free_result($rsBioStuff); ?>
Code:<?php Header("content-type: application/x-javascript");?> <?php require_once('../Connections/accessbhs.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_accessbhs, $accessbhs); $query_rs_variables = "SELECT * FROM staffbio ORDER BY bioId ASC"; $rs_variables = mysql_query($query_rs_variables, $accessbhs) or die(mysql_error()); $row_rs_variables = mysql_fetch_assoc($rs_variables); $totalRows_rs_variables = mysql_num_rows($rs_variables); mysql_select_db($database_accessbhs, $accessbhs); $query_rsCase = "SELECT bioId FROM staffbio ORDER BY bioId ASC"; $rsCase = mysql_query($query_rsCase, $accessbhs) or die(mysql_error()); $row_rsCase = mysql_fetch_assoc($rsCase); $totalRows_rsCase = mysql_num_rows($rsCase); ?> <?php do { ?> var _<?php echo $row_rs_variables['bioId'];?> = "_<?php echo $row_rs_variables['bioId'];?>"; <?php } while ($row_rs_variables = mysql_fetch_assoc($rs_variables)); ?> function switchUp(tableSelect, whereComeFrom) { switch(tableSelect) { <?php do { ?> case _<?php echo $row_rsCase['bioId']; ?>: document.getElementById(whereComeFrom).style.display="none"; document.getElementById(tableSelect).style.display="block"; document.getElementById(staffDirectory).style.display="block"; previousPage = tableSelect; break; <?php } while ($row_rsCase = mysql_fetch_assoc($rsCase)); ?> } } <?php mysql_free_result($rs_variables); mysql_free_result($rsCase); ?>
Cloudjiffy- PaaS for Developers
10-05-2020, 12:30 AM in Web Hosting Forum