php variabel til javascript og tilbage igen
Hjælp!!!Jeg kalder en javascript function der hedder moveSelected()
med nogle parametre, i den function vil jeg gerne sætte en variabel og have den retur, så jeg kan bruge den i en ny javascript function openWin(), hvordan gør jeg det??????
Her er koden:
<?PHP
require ('/config.php');
function Create_combo($mq_id,$tmp_id,$name,$tbl_name, $j_id_one, $j_id_two){
$result = mysql_query("SELECT * FROM $tbl_name")or die("Invalid query: " . mysql_error());
echo "<table class=\"box\" border=\"0\" align=\"center\" bordercolor=\"#000000\" width=\"300\" height=\"150\" cellpadding=\"0\" cellspacing=\"5\">";
echo "<tr valign=\"middle\">";
echo "<td align=\"center\">";
echo "<select size=\"5\" name=\"$name\" id=\"$j_id_one\">";
while($row = mysql_fetch_array($result)){
$id = $row[0];
$mw_title = $row[1];
$mw_id = $name."_id_".$id;
echo "<option value=\"$mw_id\">$mw_title</option>";
}
echo "</select>";
echo "</td>";
echo "<td width=\"50\" align=\"center\">";
echo "<input type=\"button\" value=\" >> \" onclick=\"moveSelected( '$j_id_one', '$j_id_two' );";
echo "openWin('$tmp_id','$mw_id','$mw_id_ny')\"><br>";
echo "<br>";
echo "<input type=\"button\" value=\" << \" onclick=\"moveSelected( '$j_id_two', '$j_id_one' );\"><br>";
echo "</td>";
echo "<td width=\"48%\">";
echo "<select size=\"5\" name=\"$name\" id=\"$j_id_two\">";
echo "</select>";
echo "</td>";
echo "</tr>";
echo "</table>";
}
?>
<script language="JavaScript" type="text/javascript">
<!--
function moveSelected( strSourceID, strTargetID )
{
var objSource = document.getElementById( strSourceID );
var objTarget = document.getElementById( strTargetID );
if( objSource.selectedIndex > -1 )
{
var objOption = objSource.options[ objSource.selectedIndex ];
var objNewOption = new Option( objOption.text, objOption.value )
var mw_id_ny = objOption.value;
window.status = mw_id_ny;
alert(mw_id_ny)
objTarget.add( objNewOption );
objSource.remove( objSource.selectedIndex );
}
}
function openWin(tmp_id,mw_id,mw_id_ny) {
alert(mw_id)
alert(mw_id_ny)
}
//-->
</script>
<HTML>
<HEAD></head>
<body>
<?PHP
Create_combo($mq_id,$tmp_id,Technology,mw_technology,selTree, selFour);
?>
</body>
</html>