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";
?>