Radio button problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shiva05
    New Member
    • Apr 2008
    • 5

    Radio button problem

    Hi frnds,
    I have a problem with radio button.
    I am using the below(check1 function) to display the length of the radio button.
    If it has more than 1 row it alerts correctly but if it has only 1 row it says undefined what is the problem

    Code:
    function check1()
    	{
    		var len;
    		len = document.artist.radio1.length;
    	    alert('rows '+len);
    	
    	//len = document.getElementById('radio1');
    	for (i= 0;i < len ;i++){
    		
    		if (document.artist.radio1[i].checked == true)
    		t = document.artist.radio1[i].value;
             
    		}
    	 document.artist.hid1.value = t;
    	 alert(t);	
    		
    	}

    Code:
    while ($rowsql1 = mysql_fetch_array($rssql1))
    {
    	$countr = $countr + 1;
    $products_id=$rowsql1['products_id'];
    $products_name=$rowsql1['products_name'];
    $categories_id=$rowsql1['categories_id'];
    $refid = $rowsql1['ref_id'];
    $new=$rowsql1['new'];
    $p=$rowsql1['products_quantity'];
    	//echo $products_name;
    $sqlcategories="select categories_name from categories_description where categories_id='$categories_id'";
    $rscategories = mysql_query($sqlcategories) or die ("couldn't find a record");
    echo "row".$categories_id;
    $c = mysql_fetch_row($rscategories);
    $categories_name = $c[0]; 
    
    if ($rowcategories == mysql_fetch_array($rscategories))
    {
    	$categories_name=$rowcategories['categories_name'];
    }
    
    <td align="center"><input type="radio" id="radio1" value="<? echo $products_id; ?>" onclick="check1();"></td>
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    please post an example of the generated html-code so that we may see what the function will do during runtime.

    kind regards

    Comment

    Working...