Jump to content

making select options to checkboxes


liquidkrep

Recommended Posts

How can change this code which is multiple select options to checkboxes instead;

 

<fieldset>
						<legend>Create a contact list</legend>
						<div>
							<label for="contacts">Available contacts</label>
							<span class="input">
								<select id="contacts" name="contacts[]" multiple="multiple">
									<?php if(!count($contacts)): ?>
									<option>No emails available</option>
									<?php else: ?>
									<?php foreach($contacts as $contact): ?>
									<option value="<?php echo $contact['recipient_id']; ?>"><?php echo $contact['email']; ?></option>
									<?php endforeach; ?>
									<?php endif; ?>
								</select>
							</span>
						</div>
					</fieldset>

 

Can anyone help me out?

 

Link to comment
https://forums.phpfreaks.com/topic/174272-making-select-options-to-checkboxes/
Share on other sites


<fieldset>
<legend>Create a contact list</legend>
	<div>
		<label for="contacts">Available contacts</label>
		<span class="input">

		<?php 

			if(count($contact)<1){

				echo 'No emails available';

			}else{

				foreach($contacts as $contact){

					echo '<input type=checkbox value="'.$contact['recipient_id'].'" name="'.$contact['recipient_id'].'" /> '.$contact['email'].'<br />';

				}//end foreach

			}//end if

		?>

	</span>
</div>
</fieldset>

 

like so?

I tried this instead;

 

<fieldset>

<legend>Create a contact list</legend>

<div>

<label for="contacts">Available contacts</label>

<span class="input">

<?php if(!count($contacts)): ?>

<?php else: ?>

<?php foreach($contacts as $contact): ?>

<input type="checkbox" value="<?php echo $contact['recipient_id']; ?>" name="contacts[]" /><?php echo $contact['email']; ?><br />

<?php endforeach; ?>

<?php endif; ?>
</span>
</div>
</fieldset>

 

 

I think the issue is now that the javascript button will not let me submit the form even though I have the checkbox checked.

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.