Jump to content

radio buttons in php


NickG21

Recommended Posts

hey everyone, i was just wondering if anyone knew a good syntax to create a set of radio buttons through php. i am using a ZervWizard class for my base and it creates drop-downs in this method:

[code]<?php foreach ($wizard->FreqOfMail as $k => $v) { ?>
<option value="<?= $k ?>"<?php if ($wizard->getValue('FreqOfMail') == $k) { ?>
<?php } ?>> <?= $v ?> </option> <?php } ?>[/code]

i was wondering if from this syntax anyone could help me dervive a way to make a set of radio buttons or a checkbox/checkboxes. any help is appreciated

thank you in advance
Link to comment
https://forums.phpfreaks.com/topic/35221-radio-buttons-in-php/
Share on other sites

Radio buttons are similar. Using what you have I'd do:
[code]
<?php
foreach ($wizard->FreqOfMail as $k => $v) {
  print '<input type="radio" value="'.$k.'"';
  if ($wizard->getValue('FreqOfMail') == $k) {
      print ' selected ';
  }
  print '">'.$v;
}

[/code]
Link to comment
https://forums.phpfreaks.com/topic/35221-radio-buttons-in-php/#findComment-166320
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.