tags:

views:

92

answers:

2
<?php
session_start(); 

if (count($_POST) > 0) { 

$_SESSION['link'] = $_POST['link']; 
} 
?>

<form method="post"> 
 Gmail: <input type="checkbox" name="link" value="gmail" id="gmail" <?php if     ($_SESSION['link'] == 'gmail') echo "checked"; ?>>
 Hotmail: <input type="checkbox" name="link" value="hotmail" id="hotmail" <?php if     ($_SESSION['link'] == 'hotmail') echo "checked"; ?>>
 <input type="submit" value="Spara"> 
</form>

Problem is if a box is checked you have to uncheck that then check another to change. Is there a way so it unchecks the checked one when i check another? that sounds weird...

Thanks

+3  A: 

There is a reason God created radio buttons. :)

Kevin
+8  A: 

You could just use Radio buttons instead, e.g:

<input type="radio" name="rdGroup1" value="John"> John
<input type="radio" name="rdGroup1" value="Jane"> Jane
Mr. Smith