HTML/CSS Form (Table) DOB line showing on two lines - html

On my websites form - my date of birth day, month and year menus are showing on two lines, I'd like them to all show on the same line instead.
When I test the code it show's on one line so I believe there must be a width issue.
You can see the issue on the right hand form (incomeprotectionstore.co.uk).
Any help would be much appreciated.
The date of birth css can be seen below:
<tr>
<td nowrap=""><label><div align="left">Date of birth</div></label></td>
<td><select name="x_C1DOB_YYYY" id="dd_dob_year" class="input-dob">
<?
for($i=1995; $i >= 1900; $i--){
?>
<OPTION value="<? echo $i; ?>" <? formSelected( $x_C1DOB_YYYY, $i ); ?>><? echo $i; ?></OPTION>
<?
}
?>
</select>
<select name="x_C1DOB_MM" id="dd_dob_month" class="input-dob">
<?
for($i=1; $i<=12; $i++){
if($i < 10) $x = "0".$i; else $x = $i;
$month = $month_name[$i-1];
?>
<OPTION value="<? echo $x; ?>" <? formSelected( $x_C1DOB_MM, $x ); ?>><? echo $month; ?></OPTION>
<?
}
?>
</select>
<select name="x_C1DOB_DD" id="dd_dob_day" class="input-dob">
<?
for($i=1; $i<=31; $i++){
if($i < 10) $x = "0".$i; else $x = $i;
?>
<OPTION value="<? echo $x; ?>" <? formSelected( $x_C1DOB_DD, $x ); ?>><? echo $x; ?></OPTION>
<?
}
?> </select>
</td>
</tr>
Thanks,
Sam

You could try wrapping your selects in an element that prevents line-wrapping like this:
<div style="white-space:nowrap;">
<select>
<select>
<select>
</div>

Set width:200px; on the <td> containing the DOB dropdowns (like it is set on the <input>s in the rest of the form)
for instance <td class = "dob-wrapper"> in the HTML and .dob-wrapper { width:200px; } in the CSS
Final answer:
Change the first <td> to <td style="width:99px;"> Then change the second <td> element to <td style="width:200px;">
If you want the boxes on the right instead of left change use 160px instead of 99px

this is the working code of birthday. try this
<div id="birthday">
<p>Birthday</p>
<table id="birthday">
<tr>
<th>
<select name="month">
<option value="">Month</option>
<option value="01" <?php if(isset($_POST['month']) && $_POST['month'] == '01') { echo 'selected="selected"'; } ?>>Jan</option>
<option value="02" <?php if(isset($_POST['month']) && $_POST['month'] == '02') { echo 'selected="selected"'; } ?>>Feb</option>
<option value="03" <?php if(isset($_POST['month']) && $_POST['month'] == '03') { echo 'selected="selected"'; } ?>>Mar</option>
<option value="04" <?php if(isset($_POST['month']) && $_POST['month'] == '04') { echo 'selected="selected"'; } ?>>Apr</option>
<option value="05" <?php if(isset($_POST['month']) && $_POST['month'] == '05') { echo 'selected="selected"'; } ?>>May</option>
<option value="06" <?php if(isset($_POST['month']) && $_POST['month'] == '06') { echo 'selected="selected"'; } ?>>Jun</option>
<option value="07" <?php if(isset($_POST['month']) && $_POST['month'] == '07') { echo 'selected="selected"'; } ?>>Jul</option>
<option value="08" <?php if(isset($_POST['month']) && $_POST['month'] == '08') { echo 'selected="selected"'; } ?>>Aug</option>
<option value="09" <?php if(isset($_POST['month']) && $_POST['month'] == '09') { echo 'selected="selected"'; } ?>>Sep</option>
<option value="10" <?php if(isset($_POST['month']) && $_POST['month'] == '10') { echo 'selected="selected"'; } ?>>Oct</option>
<option value="11" <?php if(isset($_POST['month']) && $_POST['month'] == '11') { echo 'selected="selected"'; } ?>>Nov</option>
<option value="12" <?php if(isset($_POST['month']) && $_POST['month'] == '12') { echo 'selected="selected"'; } ?>>Dec</option>
</select>
</th>
<th>
<select id="day" name="day">
<option value="">Day</option>
<?php
for($i=1; $i<=31; $i++)
{
echo '<option value="' . $i . '"';
if(isset($_POST['day']) && $_POST['day'] == $i)
{
echo ' selected="selected"';
}
echo '>' . $i . '</option>';
}
?>
</select>
</th>
<th>
<select id="year" name="year">
<option value="">Year</option>
<?php
for($i=2014; $i>=1905; $i--)
{
echo '<option value="' . $i . '"';
if(isset($_POST['year']) && $_POST['year'] == $i)
{
echo ' selected="selected"';
}
echo '>' . $i . '</option>';
}
?>
</select>
</th>
</tr>
</table>
</div>

Related

can we make slider in select options?

can we make slider/carousel in select options.below is the code and image.anyone help plz.
<select class="" id="project_type" name="project_type" title="Project Type" multiple
style="width: 410px;">
<option value="Residential" <?php if($selected_project_type == 'Residential') echo "selected";
?> >Residential</option>
<option value="Commercial" <?php if($selected_project_type == 'Commercial') echo "selected"; ?
> >Commercial</option>
<option value="Residential & Commercial" <?php if($selected_project_type == 'Residential &
Commercial') echo "selected"; ?> >Residential & Commercial</option>
<option value="Infrastructure" <?php if($selected_project_type == 'Infrastructure') echo
"selected"; ?> >Infrastructure</option>
<option value="Others" <?php if($selected_project_type == 'Others') echo "selected"; ?>
>Others</option>
enter image description here
i want all select options inline and put slider.
Selects are pretty hard to customize
A way easier will be just make slider
and change an input or even div properties when click on slide

Two action forms and two submit buttons, how to keep the values?

I have 2 action forms in the page and 2 submit buttons.
1 is zoom-level
1 is refresh rate in seconds
When I hit submit of zoom, the refresh rate is reset
When I hit submit of refresh rate, the zoom level is reset
What to do to keep the value of the other when one dropdown is set to a certain value?
I think this is a common problem where noobs struggle with, so it would be nice to have some good explanation from experts with nice guidance here...
code is:
<?php
$submittedValue = "";
$value0 = 1;
$value1 = 1.2;
$value2 = 1.5;
$value3 = 2;
if (isset($_POST["FruitList"])) {
$submittedValue = $_POST["FruitList"];
}
?>
<form action="example3b2vandaag.php" name="fruits" method="post">
<select project="FruitList" id="FruitList" name="FruitList">
<option value = "<?php echo $value0; ?>"<?php echo ($value0 == $submittedValue)?" SELECTED":""?>><?php echo "off"; ?></option>
<option value = "<?php echo $value1; ?>"<?php echo ($value1 == $submittedValue)?" SELECTED":""?>><?php echo $value1; ?></option>
<option value = "<?php echo $value2; ?>"<?php echo ($value2 == $submittedValue)?" SELECTED":""?>><?php echo $value2; ?></option>
<option value = "<?php echo $value3; ?>"<?php echo ($value3 == $submittedValue)?" SELECTED":""?>><?php echo $value3; ?></option>
</select>
<input type="submit" name="submit" id="submit" value="Set zoom level" />
</form>
<?php
$submittedValue = "";
$value0 = 1000;
$value1 = 20000;
$value2 = 30000;
$value3 = 90000;
if (isset($_POST["FruitList2"])) {
$submittedValue = $_POST["FruitList2"];
}
?>
<form action="example3b2vandaag.php" name="fruits2" method="post">
<select project="FruitList2" id="FruitList2" name="FruitList2">
<option value = "<?php echo $value0; ?>"<?php echo ($value0 == $submittedValue)?" SELECTED":""?>><?php echo $value0; ?></option>
<option value = "<?php echo $value1; ?>"<?php echo ($value1 == $submittedValue)?" SELECTED":""?>><?php echo $value1; ?></option>
<option value = "<?php echo $value2; ?>"<?php echo ($value2 == $submittedValue)?" SELECTED":""?>><?php echo $value2; ?></option>
<option value = "<?php echo $value3; ?>"<?php echo ($value3 == $submittedValue)?" SELECTED":""?>><?php echo $value3; ?></option>
</select>
<input type="submit" name="submit" id="submit" value="Set refresh milliseconds" />
</form>
I don't see any reason why you would want two forms, you can put the two select boxes into one form.
And please don't use unintelligent variable names such as $value0, $submittedValue and $Fruitlist, because this isn't about fruits.
Here are the two select boxes into one form:
<?php
$zoom = "";
$zoom0 = 1;
$zoom1 = 1.2;
$zoom2 = 1.5;
$zoom3 = 2;
$refresh = "";
$refresh0 = 1000;
$refresh1 = 20000;
$refresh2 = 30000;
$refresh3 = 90000;
if (isset($_POST["zoom"])) {
$zoom = $_POST["zoom"];
}
if (isset($_POST["refresh"])) {
$refresh = $_POST["refresh"];
}
?>
<form action="testForm.php" name="controlpanel" method="post">
ZoomLevel:<br />
<select project="ControlPanel" id="ControlPanel" name="zoom">
<option value = "<?php echo $zoom0; ?>"<?php echo ($zoom0 == $zoom)?" SELECTED":""?>><?php echo "off"; ?></option>
<option value = "<?php echo $zoom1; ?>"<?php echo ($zoom1 == $zoom)?" SELECTED":""?>><?php echo $zoom1; ?></option>
<option value = "<?php echo $zoom2; ?>"<?php echo ($zoom2 == $zoom)?" SELECTED":""?>><?php echo $zoom2; ?></option>
<option value = "<?php echo $zoom3; ?>"<?php echo ($zoom3 == $zoom)?" SELECTED":""?>><?php echo $zoom3; ?></option>
</select>
<br />
Refresh rate:<br />
<select project="ControlPanel" id="ControlPanel" name="refresh">
<option value = "<?php echo $refresh0; ?>"<?php echo ($refresh0 == $refresh)?" SELECTED":""?>><?php echo $refresh0; ?></option>
<option value = "<?php echo $refresh1; ?>"<?php echo ($refresh1 == $refresh)?" SELECTED":""?>><?php echo $refresh1; ?></option>
<option value = "<?php echo $refresh2; ?>"<?php echo ($refresh2 == $refresh)?" SELECTED":""?>><?php echo $refresh2; ?></option>
<option value = "<?php echo $refresh3; ?>"<?php echo ($refresh3 == $refresh)?" SELECTED":""?>><?php echo $refresh3; ?></option>
</select><br />
<input type="submit" name="submit" id="submit" value="Set configurations" />
</form>
To use the data you get from the form you can use $_POST["zoom"] and $_POST["refresh"], because that's what the name properties of the select boxes are.
See http://www.w3schools.com/php/php_form_complete.asp for more information on html forms and how to use the $_POST data.

HTML to PHP dropdown menu

I have this html part for a dropdown menu:
<form name="navList" onsubmit="return submitForm();">
<select name="subMenu">
<option value> </option>
<option value> CR_ID </option>
<option value> CR_HEADLINE </option>
<option value> CRI_CLOSEDATE </option>
<option value> CRI_ASSIGNEE </option>
</select>
How can I change this into php, using this function?
foreach($array as $key=>$value)
{
$html .= "<option value='$key'>$value</key>";
}
echo "<select name="process">$html</select>";
You forget to add escape sequences in your output . Please refer this demonstration:-
$optionArray = array(
0 => 'CR_ID',1=> 'CR_HEADLINE',
2 => 'CRI_CLOSEDATE',3 => 'CRI_ASSIGNEE'
);
foreach($optionArray as $key=>$value)
{
$html .= "<option value='$key'>$value</key>";
}
echo "<select name=\"process\">".$html."</select>";
OR
echo '<select name="process">'.$html.'</select>';
echo "<select name=\"process\">".$html."</select>";
You needed to escape your quotes.
<?php
$html ='';
$myArray = array(0 => '',1 => 'CR_ID',2=> 'CR_HEADLINE', 3 => 'CRI_CLOSEDATE',4 => 'CRI_ASSIGNEE');
foreach($myArray as $key=>$value)
{
$html .= "<option value='$key'>$value</key>";
}
echo "<select name=\"process\">".$html."</select>";
Link - http://codepad.viper-7.com/YpccFw

html select list selected item and maximum value can be selected

HELLO,
i have an html select list, and i want: the selected number to be a given value $content->number, and the maximum value to be $content->product_type->stock_2 if it is less than 5, or 5 if it is greater than 5.
now i have:
<select class="number" name="number">
<? $max = $content->product_type->stock_2 > 5 ? 5 : $content->product_type->sale_stock; ?>
<option value="<?= $content->number ?>"><?= $content->number; ?> </option>
<? for ($i = 1; $i <= $max; $i++):?>
<option <?php if($content->product_type->stock_2 == $i) echo 'selected="selected"' ;?> value="<?= $i ?>"><?= $i; ?></option>
<? endfor; ?>
</select>
but it shows me twice the selected value $content->number. i'm sure i am mistaking somewhere.
Any suggestions?
thank you!
I do not know whether I correct understood what you want to do, but try this:
<select class="number" name="number">
<? $max = $content->product_type->stock_2 > 5 ? 5 : $content->product_type->sale_stock; ?>
<option value="<?= $content->number ?>"><?= $content->number; ?> </option>
<? for ($i = 1; $i <= $max; $i++):?>
<? if ($i != $content->number): ?>
<option <?php if($content->product_type->stock_2 == $i) echo 'selected="selected"' ;?> value="<?= $i ?>"><?= $i; ?></option>
<? endif; ?>
<? endfor; ?>
</select>

Set current date in form select lists

Basically I have HTML form which reads in a date from a user, for a hotel booking system.
I have 3 lists, one for day, one for month and one for year.
<SELECT NAME="month">
<OPTION VALUE="1"> Jan
<OPTION VALUE="2"> Feb
<OPTION VALUE="3"> March and so on
</SELECT>
and the same for year(2010 - 2013) and day(1 -31).
Is there any way I can have the default value in the day list set to the current day, the default value in the month list set the the current month, and the default value in the year list set to the current year? Rather than manually having to do it.
Thanks in advance for the help!
You will need to use JavaScript. Here's an example, using jQuery:
<script type="text/javascript">
$(document).ready(function(){
var CurrentDate=new Date();
$("#year").val(CurrentDate.getYear());
$("#month").val(CurrentDate.getMonth());
$("#day").val(CurrentDate.getDate());
});
</script>
Here's the code in action.
You will have to use javascript. or any client side scripting to do this. I can suggest you some examples but you must first understand the concept of client side scripting
In response to #sushil bharwani you can also use a server side language if you are comfortable with that. PHP is installed on most web hosts you find now days and a plus (as opposed to javascript) is that it is guaranteed to work. The clients user agent does not matter.
This is php code:
<?php
$month = date('F');
if($month == "January") { $jan = "selected"; }
if($month == "February") { $feb = "selected"; }
if($month == "March") { $mar = "selected"; }
if($month == "April") { $apr = "selected"; }
if($month == "May") { $may = "selected"; }
if($month == "June") { $june = "selected"; }
if($month == "July") { $july = "selected"; }
if($month == "August") { $aug = "selected"; }
if($month == "September") { $sep = "selected"; }
if($month == "Octomber") { $oct = "selected"; }
if($month == "November") { $nov = "selected"; }
if($month == "December") { $dec = "selected"; }
?>
Now select below code, then copy and paste between the body-tag:
<select name="start_month" id="start_month">
<option value="January" <?php echo $jan; ?> >January</option>
<option value="February" <?php echo $feb; ?> >February</option>
<option value="March" <?php echo $march; ?> >March</option>
<option value="April" <?php echo $apr; ?> >April</option>
<option value="May" <?php echo $may; ?> >May</option>
<option value="June" <?php echo $june; ?> >June</option>
<option value="July" <?php echo $july; ?> >July</option>
<option value="August" <?php echo $aug; ?> >August</option>
<option value="September" <?php echo $sep; ?> >September</option>
<option value="Octomber" <?php echo $oct; ?> >Octomber</option>
<option value="November" <?php echo $nov; ?> >November</option>
<option value="December" <?php echo $dec; ?> >December</option>
</select>
Thanks.
Note: Link for the complete example: http://www.javascriptkit.com/script/script2/curdateform2.shtml