|
|
|
The following example somehow gives the opportunity to combine Javascript and PHP
variables, which usually would only be possible in one way, giving a Javascript the variables
from PHP, but not reverse.
The trick is, to make the selectbox send a value with two variables:
1. the variable from PHP,
2. the value of this variable
As this will be an array for javascript, it need to be split into single parts again and
the value can be used in another formfield.
With enough fantasy, this code can solve a lot of ideas, I guess.
Let me know...
n-dee
ark@anyweb.at
--------------------
Put this code in a PHP file:
<html>
<script language="JavaScript">
<!--
function GetVarValue(field) {
selected=false;
for (Count = 0; Count < document.forms[0].strCfgVar.length; Count++){
if(document.forms[0].strCfgVar[Count].selected){
selected=true;
var string = document.forms[0].strCfgVar[Count].value;
var stringArray = string.split(",");
strCfgVarValue = stringArray[1];
}
}
if ((navigator.appName.indexOf("Microsoft") != -1) && (parseInt
(navigator.appVersion) >= 4)){
document.forms[0].currVal.style.backgroundColor="yellow";
}
document.forms[0].currVal.value=strCfgVarValue;
document.forms[0].currVal.focus();
return true;
}
//-->
</script>
<?
// these data should come from a config-file e.g.
// with include("FILE");
$cfgDbHost="localhost";
$cfgDbUser="AdminUser";
?>
<table align="center" border="0"><tr>
<form method="POST" name="selectform" action="<? echo $PHP_SELF ?>">
<tr><td>Variable: </td><td>
<select name="strCfgVar" onChange="GetVarValue(this)">
<option value=""></option>
<option value="cfgDbHost,<? echo $cfgDbHost ?>">DB-Host</option>
<option value="cfgDbUuser,<? echo $cfgDbUser ?>">DB-User</option>
</select>
</td>
<td>Current Value: <input type="text" name="currVal" size="30"></td><td>
</tr></table>
</html>
|
|
| clearing variables in php3 Categories : Variables, Arrays, PHP | | | PHP4 session helper HTML file.
Categories : PHP, Java Script, HTML and PHP, Sessions | | | Dynamic Calender in PHP, Javascript and HTML. Categories : PHP, Java Script, HTML and PHP, Calendar | | | Building dynamic menus with PHP & MySQL (ADO), JavaScript and CSS Categories : PHP, Databases, MySQL, Java Script, User Interface | | | PHP Dump in html format the contents of one array variable with a recursive list of the nested array variables inside. Categories : PHP, Arrays, Variables | | | translate.php - Assocciative array example, passing a reference to a function. Categories : PHP, Arrays, Languages, Variables | | | This functions compares the current PHP version with a
desired version. Because of the 3 tiered version system, a
direct compare of a string to phpversion() will not be
accurate. Categories : PHP Configuration, PHP, Variables | | | Pull Down Surfing - Surf on Change Categories : Java Script, MySQL, HTML and PHP, PHP, Databases | | | The Ajax Tree view class fetches data from a db for the requested parent category id. The data is then stored in an array and converted into JSON (Javascript Object Notation) format. This format is then used by JavaScript for populating tree view. Categories : PHP, PHP Classes, Java Script, AJAX, Databases | | | getting the name of the current script and query string Categories : PHP, Global Variables, Variables, URLs | | | Zephyr: AJAX Based Framework for PHP5 Developers Categories : PHP, AJAX, Frameworks, Java Script, Web Applications | | | Array values from javascript to php Categories : PHP, Java Script, Arrays | | | Create HTML forms dynamicly using Javascript & PHP Categories : PHP, PHP Classes, Java Script | | | Check parameters validity. Paranoia was designed to check the validity of the parameters that a php page will receive after a form submission. It can be used to check the variables sent by POST or GET Categories : Algorithms, HTML and PHP, PHP, Variables | | | Builds JavaScript that updates the contents of one selector based on another. Categories : HTML, Java Script, PHP, Complete Programs, General | |
|
|
|