哦,谢谢谢谢,谢谢大家,这样可以了。对了,再问一个问题。 echo "<script LANGUAGE=JavaScript>window.confirm('$String');</script>"; 这个window.confirm()怎么知道 用户取的是yes or no呢??
对了,再问一个问题。 echo "<script LANGUAGE=JavaScript>window.confirm('$String');</script>"; 这个window.confirm()怎么知道 用户取的是yes or no呢?? ------------------------------------------------------------------------------*** 这个问题GOOGLE或MSDN都能解决 ***confirm Method--------------------------------------------------------------------------------Displays a confirmation dialog box that contains an optional message as well as OK and Cancel buttons.SyntaxbConfirmed = window.confirm( [sMessage]) ParameterssMessage Optional. String that specifies the message to display in the confirmation dialog box. If no value is provided, the dialog box does not contain a message. Return ValueBoolean. Returns one of the following possible values:true The user clicked the OK button. false The user clicked Cancel button. ResThe title bar of the confirmation dialog box cannot be changed.Standards InformationThere is no public standard that applies to this method.
<?
for($i=1;$i<10;$i++)
{
?>
<td width="100%" ><input type="checkbox" name="select[<?echo $i?>]" value="<?echo $i?>" ></input></td>
<?
}
?>
</form>
我这样写行吗??
这样该怎么取value的值呢??
{
$name = 'select['.$i.']';
if($_POST[$name])
{
$j++;
$taskId[$j]=$_POST[$name];
}
}
我这样怎么都取不到$_POST[$name]的值。
是不是我哪里写错了。
请各位朋友帮帮我。:(
Array
(
[select] => Array
(
[1] => 1
[3] => 3
[5] => 5
[7] => 7
[9] => 9
))
这个你可以通过print_r($_POST)看到,而不是所希望的
Array
(
[select[1]] => 1
[select[3]] => 3
[select[5]] => 5
[select[7]] => 7
[select[9]] => 9
)因此你需要改变一下你的表单的命名方式。
至于为什么出现这个我就不知道了,还希望知道原因的大虾能指点一下。
<?
for($i=1;$i<10;$i++)
{
?>
<td width="100%" ><input type="checkbox" name="select[]" value="<?echo $i;?>" ></input></td>
<?
}
?>
</form>
and use $_POST['select'][$i] to get the data.($i>=0)
<?
for($i=1;$i<10;$i++)
{
?>
<td width="100%" ><input type="checkbox" name="select[]" value="<?echo $i;?>" ></input></td>
<?
}
?>
</form>
for($i=1;$i<10;$i++)
{
if( $_POST['select'][$i])
{
$j++;
$taskId[$j]=$_POST['select'][$i]);
}
}
现在我已经改成这样了,
可是if语句还是进不去,取得的$_POST['select'][$i的值还是为空。
<form enctype='multipart/form-data' action="" method="POST" name="submit" >
<?
for($i=1;$i<10;$i++)
{
?>
<tr><td width="100%" ><input type="checkbox" name="select[]" value="<?echo $i;?>" ></input><?echo $i;?></td></tr>
<?
}
?>
<tr><td width="100%" ><input type="submit" name="sub" value="submit" ></input></td></tr>
</form>
</table>
<?
print_r($_POST);
$j=0; //初始化赋值
for($i=0;$i<10;$i++) //$i=1 改为 $i=0
{
if( $_POST['select'][$i] )
{
$j++;
$taskId[$j]=$_POST['select'][$i]; //此处多 “)”
}
}
print_r($taskId);
?>
if( $_POST['select'][$i] )
改为
if( is_numeric($_POST['select'][$i]) )
echo "<script LANGUAGE=JavaScript>window.confirm('$String');</script>";
这个window.confirm()怎么知道 用户取的是yes or no呢??
echo "<script LANGUAGE=JavaScript>window.confirm('$String');</script>";
这个window.confirm()怎么知道 用户取的是yes or no呢??
------------------------------------------------------------------------------*** 这个问题GOOGLE或MSDN都能解决 ***confirm Method--------------------------------------------------------------------------------Displays a confirmation dialog box that contains an optional message as well as OK and Cancel buttons.SyntaxbConfirmed = window.confirm( [sMessage])
ParameterssMessage Optional. String that specifies the message to display in the confirmation dialog box. If no value is provided, the dialog box does not contain a message. Return ValueBoolean. Returns one of the following possible values:true The user clicked the OK button.
false The user clicked Cancel button. ResThe title bar of the confirmation dialog box cannot be changed.Standards InformationThere is no public standard that applies to this method.