You are here: validate button radio in form « PHP Programming Language « IT news, forums, messages
validate button radio in form

Posted by elia on 03/27/07 12:43

Hello,

I use php and javascript on a form.
My validate script doesn't work with radio button. What's wrong? I
want to be sure that one of the button is press. M or F

I get on my first page:

<?php
$Genre=$_POST['genre'];
?>
<head>
<script type="text/javascript">
function verif_champs()
{

if(document.forml.Genre.value == "")
{
alert("Choose the gender!");
document.forml.Reference.focus();
return false;
}
</script>
</head>
<body>
<form name="forml" method="post" onSubmit="return verif_champs()"
action="test22.php" >
<table>
<tr><td>
<?
$checked[$_POST['Genre']]='checked="checked"';
echo '<input type = "radio" name="Genre" value="F"
'.$checked['F'].'/>';
echo '<input type = "radio" name="Genre" value="M"
'.$checked['M'].'/>';
?> <input type="submit"></td></tr>
</table>
</form>

On my page 2:

<?php
$Genre=$_POST['Genre'];
?>
<body>
<table>
<tr><td>
<form name="form2" ACTION="test11.php" method="post">
<? foreach ($_POST as $key=>$val)
{
echo '<input type = "hidden" name="'.htmlentities($key).'"
value="'.htmlentities($val).'" />';
}
?>
<? echo $Genre ?>
<input type="submit" name="Submit2" value="Back" />
</form>
</td></tr></table>
</body>

Thanks a lot. Pascal

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация