vendredi 27 février 2015

Prevent new line from being formmed within a div


Vote count:

0




I have the following HTML/PHP sign up form:



<div class="form_block" id="dob-check" style="display:none; float:left">
<p><label for="sign_up_dob_day">DOB</label> <select name="sign_up_dob_day" id="sign_up_dob_day" class="required"><option value="">-</option><?php for($day = 1; $day <= 31; $day++) : ?>
<option value="<?php echo $day ?>" <?php echo set_select('sign_up_dob_day', $day, ((is_array($dob) && count($dob) == 3 && $dob[2]==$day)? true : false)); ?>><?php echo $day ?></option>
<?php endfor; ?>
</select>
<select name="sign_up_dob_month" class="required">
<option value="">-</option>
<?php $months = getMonthsArray(); ?>
<?php for($month = 1; $month <= 12; $month++) : ?>
<option value="<?php echo $month ?>" <?php echo set_select('sign_up_dob_month', $month, ((is_array($dob) && count($dob) == 3 && $dob[1]==$month)? true : false)); ?>><?php echo $months[$month - 1] ?></option>
<?php endfor; ?>
</select>
<select name="sign_up_dob_year" class="required">
<option value="">-</option>
<?php for($year = 2005; $year >= 1930; $year--) : ?>
<option value="<?php echo $year ?>" <?php echo set_select('sign_up_dob_year', $year, ((is_array($dob) && count($dob) == 3 && $dob[0]==$year || (empty($dob[0]) && $year==1990)))? true : false); ?>><?php echo $year ?></option>
<?php endfor; ?>
</select>
<?php echo form_error('sign_up_dob_day'); ?>
<a class="hand" id="dob-why" onclick="showMessage()"> Why do we need this?</a></p>
</div>


Which displays as follows:


enter image description here


However, if a user fails to enter a DOB, the formatting of the select boxes gets completely messed up, as below:


enter image description here


I guess its because the width of the div is not enough when adding the 'field required' text.


I have tried putting an outer div but this did not work. I have also tried floating left, but this also did not work.


I am new to PHP so cannot see how to remove the second 'field required' message-this may possibly help?


Any other ideas eg prevent a new line being formed within the div?



asked 32 secs ago

Alex

40






Prevent new line from being formmed within a div

Aucun commentaire:

Enregistrer un commentaire