我必须从$_POST
将2个id-s放在一起,然后我想爆炸它们,例如:
我的id-s是38和310.我在我的html文件中将id-s设为id =“38.310”。
$_POST
之后我想爆炸id:s:
$id=$_POST['id'];
echo($id); // Gives 38.31
$new_id = explode(".", $id);
echo($new_id[0]); // Gives 38
echo($new_id[1]); // Gives 31
是否有办法让这些id-s不圆?
我需要38
和310
! ID 310
也可以是1003000
...
编辑:
function dostuff(document, message, id, action) {
var eingabe;
eingabe = confirm(message);
if (eingabe === true) {
document.msgform.action.value = action;
document.msgform.id.value = id;
document.msgform.submit();
} else {
return true;
}
return false;
}
LINK
<a href="#" onclick="dostuff(document, 'MESSAGE',<?php echo($row['vID']);?>.<?php echo($row['id']);?>,'FITTER_fitter_repaired');" class="button small red" >ACTION</a>
$ row ['vID'] = 38
$ row ['ID'] = 310
我的提交看起来像这样
<form enctype="multipart/form-data" name="msgform" action="" method="post">
<input type="hidden" value="" name="action"/>
<input type="hidden" value="" name="id"/>
</form>
答案 0 :(得分:5)
不是100%肯定你为什么这样做,但为什么不使用像
这样的POST数组id[]=38&id[]=310
答案 1 :(得分:2)
答案 2 :(得分:1)
或者,如果您不理解@Lee回答,您可以使用除.
以外的其他内容作为分隔符,因此PHP不会假设变量是数字。
最好不要使用昏迷,因为这是一些国家的小数。
例如,使用美元符号`id =“38 $ 310”
和$new_id = explode("$", $id);
答案 3 :(得分:1)
我不知道函数dostuff
正在做什么,但Javascript是邪恶的。在价值观附近加上引号。这样就不会涉及转换,它会以字符串形式发布。
<a href="#"
onclick="dostuff(document, 'MESSAGE', '<?php echo($row['vID']);?>.<?php echo($row['id']);?>','FITTER_fitter_repaired');" class="button small red" >ACTION</a>
^ ^
编辑:
但我也认为李的解决方案会更好。只需输入2个输入字段并将其填入dostuff
功能。您还可以为输入字段指定id,以便更容易填充。
<input id="id1" type="hidden" value="" name="id[]"/>
<input id="id2" type="hidden" value="" name="id[]"/>