javascript:
<script type="text/javascript">
function valButton(btn) {
var cnt = -1;
for (var i=btn.length-1; i > -1; i--) {
if (btn[i].checked) {cnt = i; i = -1;}
}
if (cnt > -1) return btn[cnt].value;
else return null;
}
function valForm(form) {
var btn = valButton(form.value);
if (btn == null) alert('Kein Radio-Button ausgewählt');
if(btn != null) document.setfav.submit();
}
</script>
我的表格:
<form name="setfav" action="account/favsave" method="POST">
.
<input type="radio" name="group_shops" value="2">Supermarkt</input>
.
<input class="button" type="button" value="Add" onclick="valForm(setfav); ">
</form>
使用 symfony 1.4
当我做onclick时,根本没有任何动作。感谢帮助!