0

hi all,
i hav a problem so in order to solve that i need to keep the radio button value in a session.but i am not getting it how to keep. so any can can say me..
Thank u.

<?php
ob_start();
@session_start();
require_once ("check.php"); 
include 'connection.php';
$query= mysql_query("SELECT projectassign FROM projectassign where userid=(select userid from users where username='$username' and role='2')");
mysql_error();
$num=mysql_num_rows($query);  
 ?>
 <head>  
 <body>
 <link rel="stylesheet" type="text/css" href="style.css"/>
 <script language="javascript" type="text/javascript">
        function check()
        {
            if(document.getElementById('radio[]').value == "")
            {
                alert('Please select project');
                return false;
                
            }
        }
        </script>
 <form>
 <table width="100%">
<tr><td><img src="Logofinalcopy.gif">
</td></tr></table><br><hr style="color: red;">
<table align="right"><tr> <td></td>
        <td align="right" style="color: navy;"><strong><?php echo "Welcome ".$_SESSION[username];?>,</strong></td><td><a href="Logout.php">Logout</a></td>
    </tr></table>  
        
 <br><br>
 <table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 500px" bordercolor="red">
 <tr>
 <th></th>
 <th style="color: navy;">Projectassign</th>
 </tr>
 <?php
     $sno=1;
    while($row=mysql_fetch_array($query, MYSQL_ASSOC)){
?>
 <tr>
    <td><input name="radio" type="radio" id="radio[]" checked="checked" value="<?php echo $row['projectassign'];?>"></td> 
    <td><?php echo $row['projectassign'];?></td>
 </tr>
 <?php
   $sno=$sno+1;   
}  
?>
 </table>
 <table align="center"><td align="center">
 <input type="submit" name="Submit"  value="Submit"></td>
 </table>
 </body></head>
4
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by SKANK!!!!!
0

you say you need the value in a session? You can do this with

if (isset($_POST['submit'])){
$_SESSION['radio'] = $_POST['radio'];
}
0

First, you need to assign a "name" attribute to your checkbox in HTML in order to be able to see its value on the server side.

<input type="checkbox" id="radio1" name="radio[]" value="1" />

Second, the way to check whether a radio button is checked in JavaScript is to check its checked property.

if (!document.getElementById("radio1").checked) {
    alert("Please select the radio button.");
    return false;
}

Hope this helps.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.