We help IT Professionals succeed at work.

add radiobutton button to a list of template

usmbay
usmbay asked
on
300 Views
Last Modified: 2008-09-22
here a function to display a list of template, and I want to add a radiobutton beside each template to mark it as a defualt

function getListTemplate()
{
      $query = "SELECT tfr.titre as titrefr, ten.titre as titreen, tfr.corps as corpsfr, ten.corps as corpsen, tfr.id as idTemplatefr, ten.id as idTemplateen FROM template as tfr, template as ten WHERE tfr.deleted='n'  AND tfr.idHotel = ".$_SESSION["SES_idHotel"]." AND tfr.idLanguage = 2 AND ten.idLanguage = 1";
      $res = shoot_query($query);

      $i=1;
      while ($row = mysql_fetch_assoc($res))
      {
            $onclick = "parent.ifrCorrespondance.location.href = 'form.php?action=".CORRESPONDANCE_TEMPLATE."&id=".$row["idTemplatefr"]."';
                              parent.ifrTitle.location.href = 'form.php?action=".CORRESPONDANCE_TITLE."&titre=".CORRESPONDANCE_TITLE_TEMPLATE."';
                              parent.document.getElementById('ifrHeader').style.display = 'none';
                              parent.document.getElementById('divResultat').style.display = 'none';
                              parent.document.getElementById('ifrList').style.display = 'none';
                              parent.document.getElementById('ifrLegend').style.display = 'none';
                              parent.document.getElementById('ifrCorrespondance').style.display = 'inline';";
            $color       = ($i%2==0) ? "#F2F2F2" : "white";
            $strFR  = ($row["titrefr"] == "") ?
                          "<TABLE width=\"100%\" cellpadding=\"0\"><TR bgcolor=\"$color\" height=\"100%\"><TD width=\"100%\" align=\"center\"><B>".LB_EMPTY2."</B></TD></TR></TABLE>" :
                          "<TABLE width=\"100%\" cellpadding=\"0\"><TR bgcolor=\"$color\"><TD width=\"2%\">&nbsp;</TD><TD>&nbsp;</TD></TR>".
                          "<TR bgcolor=\"$color\"><TD>&nbsp;</TD><TD><B>".$row["titrefr"]."</B></TD></TR>".
                          "<TR bgcolor=\"$color\"><TD>&nbsp;</TD><TD>".$row["corpsfr"]."</TD></TR>".
                          "<TR bgcolor=\"$color\"><TD colspan=\"2\">&nbsp;</TD></TR></TABLE>";

            $strEN  = ($row["titreen"] == "") ?
                          "<TABLE width=\"100%\" cellpadding=\"0\"><TR bgcolor=\"$color\" height=\"100%\"><TD width=\"100%\" align=\"center\"><B>".LB_EMPTY2."</B></TD></TR></TABLE>" :
                          "<TABLE width=\"100%\" cellpadding=\"0\"><TR bgcolor=\"$color\"><TD width=\"2%\">&nbsp;</TD><TD>&nbsp;</TD></TR>".
                          "<TR bgcolor=\"$color\"><TD>&nbsp;</TD><TD><B>".$row["titreen"]."</B></TD></TR>".
                          "<TR bgcolor=\"$color\"><TD>&nbsp;</TD><TD>".$row["corpsen"]."</TD></TR>".
                          "<TR bgcolor=\"$color\"><TD colspan=\"2\">&nbsp;</TD></TR></TABLE>";

            $str   .= "<TR bgcolor=\"$color\" onclick=\"$onclick\" style=\"cursor: hand;\"><TD width=\"50%\" style=\"border-right: 1 solid silver; border-bottom: 1 solid silver;\" valign=\"middle\">".$strFR."</TD>".
                          "<TD valign=\"middle\" style=\"border-bottom: 1 solid silver;\">".$strEN."</TD></TR>";
            $i++;
      }

      return "<TABLE width=\"100%\" cellpadding=\"0\">$str</TABLE>";
}
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2004

Commented:
How do you determine if the record is a default or not?  Will the radio button be expected to do anything other than indicate a default?  (for example, to set a default...)

Author

Commented:
I will get the value from the select statment
" SELECT tfr.isDefault "
CERTIFIED EXPERT
Top Expert 2004
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.