| Subiectul anterior :: Subiectul următor |
| Autor |
Mesaj |
z.m
Data înscrierii: 25/Feb/2005
Mesaje: 328
|
| Trimis: Mie Ian 11, 2006 9:30 pm Titlul subiectului: checkbox |
|
|
Am un form si in el un checkbox.
<form method='post' action='new.php'>
<input type='text' name='username'>
<input type='text' name='password'>
<input type='checkbox' name='checkbox' value='yes'>
<input type='submit' name='submit' value='Submit'>
Daca checkbox-ul nu este selectat vreau sa imi apara un pop-up cu un text
"Pleace check box to indicate you have read and accepted the terms and conditions of this site". |
|
| Sus |
|
Vic
Data înscrierii: 12/Noi/2005
Mesaje: 213
Locație: victorstanciu.ro
|
| Trimis: Joi Ian 12, 2006 12:43 pm Titlul subiectului: |
|
|
Poftim:
Cod:
<script language="javascript" type="text/javascript">
function check(){
chk=document.getElementById('checkbox').checked;
if (chk==true){
document.getElementById('formular').submit();
}else{
alert('Bifeaza checkbox');
}
return true;
}
</script>
<form method="post" action="new.php" id="formular" name="formular">
<input type="text" name="username" />
<input type="text" name="password" />
<input type="checkbox" name="checkbox" id="checkbox" />
<input type="button" name="trimite" value="Submit" onclick="check()" />
</form>
|
|
| Sus |
|
z.m
Data înscrierii: 25/Feb/2005
Mesaje: 328
|
| Trimis: Joi Ian 12, 2006 8:07 pm Titlul subiectului: |
|
|
Ce mi-ai dat tu merge dar daca pun la mine in formular nu merge.Eu la submit am o poza,poate de aia.Ideea e ca daca nu bifez checkbox-ul,imi apare alert-ul,dar cand dau ok la alert imi intra in new.php,unde verific formularul.
<script language="javascript" type="text/javascript">
function check(){
chk=document.getElementById('checkbox').checked;
if (chk==true){
document.getElementById('formular').submit();
}else{
alert('Bifeaza checkbox');
}
return true;
}
</script>
<form method='post' action='new.php' id="formular" name="formular">
<input name="name" type="text" size="20" <?php print "value='$username'";?>
<input name="password" type="password" size="20" <?php print "value='$passwordz'"; ?> />
Terms:
<td><input type="checkbox" name="checkbox" id="checkbox" /></td>
Please tick box to indicate you read and accepted the terms
<input name="submit" type="image" src="images/butt/go.jpg" onclick="check()" width="28" height="28" align="absmiddle" border="0" vspace="0"> |
|
| Sus |
|
z.m
Data înscrierii: 25/Feb/2005
Mesaje: 328
|
| Trimis: Lun Ian 16, 2006 9:33 pm Titlul subiectului: |
|
|
| Nu stie nimeni? |
|
| Sus |
|
carco
Data înscrierii: 27/Mai/2004
Mesaje: 2796
Locație: Bucuresti
|
| Trimis: Lun Ian 16, 2006 10:51 pm Titlul subiectului: |
|
|
Pai pune return false altfel de unde sa stie ca e ceva in neregula?
Cod:
else{
alert('Bifeaza checkbox');
return false;
}
iar functia check() ar trebui pusa pe eventul onsubmit la form, nu pe onclick la buton:
form action='...' onsubmit="return check()" ... |
|
| Sus |
|
PHPRomania Bot
Bot Member
Data înscrierii: 27/Dec/2007
Mesaje: 1
Locaţie: Server Google |
| Trimis: Mie Dec 26, 2007 7:01 pm Titlul subiectului: Ad |
|
|
|
|
|
| Sus |
|
| |