Si j'ai choisi la valeur de l'option 3, affichez 3 zone de texte.getElementById ne peut pas obtenir la valeur de l'ID html
1.Cette image est le résultat de ce que je veux.
(utilisation style_display_on(), visible/cachée, aucun) Mais ce dosen't travail. Est-ce que je manque quelque chose?
(tableau php convertit en javascript tableau,
puis compter tableau à partir de PHP est utilisé par la valeur getElementById de javascript ....)
<?php
$arr[0] = "10.1.35.31";
$arr[1] = "10.1.35.122";
$arr[2] = "10.1.35.133";
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../css/main.css">
<script type="text/javascript">
function getR() {
document.getElementById("ipcnt").value = "<?php echo count($arr); ?>";
<?php
for($i = 0; $i < count($arr); $i++) {
echo "document.getElementById(\"" . "mmeremoteip" . $i . "\").value = \"" . $arr[$i]. "\";\n";
}
?>
}
function mmeswitch(){
<?php
for($i = 0; $i < 8; $i++){
echo "document.getElementById(\"mmeremoteip". $i . "\").style.visibility = \"hidden\";\n";
echo "document.getElementById(\"mmeremoteip". $i . "\").style.display = \"none\";\n";
}
for($i = 0; $i < 8; $i++){
echo "if(document.getElementById(\"ipcnt\").value == " . ($i+1) . ") { \n";
for($j = 0; $j < $i+1; $j++) {
echo "document.getElementById(\"mmeremoteip". $j . "\").style.visibility = \"visible\";\n";
echo "document.getElementById(\"mmeremoteip". $j . "\").style.display = style_display_on();\n";
}
echo "}\n";
}
?>
</script>
</head>
<body onLoad="getR();">
<form name="save" method="post">
<h1>TEST</h1>
<table>
<tr id="ipcnt"><td colspan="2">No. of IP</td>
<td><select name="ipcnt" size="1" onChange="mmeswitch();">
<?php
for($i = 1; $i <= 8; $i++) {
echo "<option value='". $i ."'>". $i ."</option>\n";
}
?>
</select></td>
</tr>
<?php
for($i = 0; $i < 8; $i++) {
echo "<tr id=\"mmeremoteip".$i."\"><td class=\"param\" colspan=\"2\">MME Remote IP" . ($i+1) . "</td>\n";
echo "<td><input type=\"text\" name=\"mmeremoteip" . $i . "\" class=\"inputParam\" size=\"20\" maxlength=\"15\" value=\"".$arr[$i] ."\"></td></tr>\n";
}
?>
</table>
</body>
</html>
Pouvez-vous fournir la version rendue - dire sans tout le php obscurcissement? On dirait que vous pourriez avoir plus d'espace, mais je ne peux pas le dire. –
Vous avez injecté le code php à l'intérieur de la fonction js –
désolé !! J'entre le code du tableau php .. !! – kara