Hi ,
I am stuck with a problem ....
Can i integrate a PHP code in a JavaScript code ?
for example in this codei want to incorporate these options(MIM,MICE) from a database in this JavaScript code ?
<html>
<head>
<title>Dual Selections</title>
<script type="text/javascript">
var a = ['|-- Please Select --','|MIM','|MICE']; // automatic value assignments
var b = ['|-- Please Select --','123|IGI','456|ERE']; // demonstration of value assignments
function choice(IDS,t){
s = document.getElementById(IDS);
for(var i = s.options.length; i >= 0 ; i--) { s.options[i] = null; }
if(t != 0){
var z = [];
switch (t) {
case '1' : z = a; break;
case '2' : z = b; break;
default : alert('Invalid entry: '+IDS+' : '+t+'\n\n'+z); break;
}
var tmp = [];
for(i = 0; i < z.length; i++ ) {
tmp = z[i].split('|')
if (tmp[0] == '') { tmp[0] = tmp[1]; }
s.options[i] = new Option(tmp[1],tmp[0],false,false);
}
}
}
</script>
</head>
<body>
<SELECT id="INSTITUTE" onChange="choice('CHAIN',this.value)">
<option value="0">-- Please Select --</option>
<option value="1">ISIMS</option>
<option value="2">ISGI</option>
</SELECT>
<!-- onChange below only for testing purposes -- not needed -->
<SELECT id="CHAIN" onChange="alert('Value: '+this.value)"></SELECT>
</body>
</html>
So please help me.


Reply With Quote


Bookmarks