Input fields drop down MM/YY - html

I am trying to edit a plugin field to use a drop down Expiry but need little bit of help. Here is what I have so far:
function payment_fields()
{
if ( $this->description )
echo wpautop(wptexturize($this->description));
echo '<label style="margin-right:46px; line-height:40px;">Credit Card Number:</label> <input type="text" name="aim_credircard" /><br/>';
echo '<label style="margin-right:30px; line-height:40px;">Credit Card Expiry (MM/YY) :</label> <input type="text" style="width:50px;" name="aim_ccexpdate" maxlength="4" /><br/>';
echo '<label style="margin-right:89px; line-height:40px;">CVV :</label> <input type="text" name="aim_ccvnumber" maxlength=4 style="width:40px;" /><br/>';
}
I want to be able to edit the following code to reflect a drop down month and year without creating a problem for the submission the front end and SELECT and SUBMIT the way it is right now.
echo '<label style="margin-right:30px; line-height:40px;">Credit Card Expiry (MM/YY) :</label> <input type="text" style="width:50px;" name="aim_ccexpdate" maxlength="4" /><br/>';
Thank you

Related

How to check if a value is empty and return dummy text like NA

I have a input field that has data pulling form the database, however when the data base is empty the input field displays the disabled that is used to disable the field when not editable.
For example in my html:
<label for="fname">CompanyCode:</label>
<input type="text" id="fname" name="fname" value={{$id->CompanyCode}} disabled>
This above pulls data however if there is now data to pull it uses the "disabled" word as the value and then the field doesn't become disabled.
Can I use a condition to overcome this using something like:
<label for="fname">CompanyCode:</label>
<input type="text" id="fname" name="fname"
value= #if($id->CompanyCode) count() == 0)
<td colspan="5" class="text-center"> Nothing Found </td>
#endif
disabled>
I was able to get the answer :
<label for="fname">CompanyCode:</label
<input type="text" id="fname" name="fname" value="{{ $id->CompanyCode}}" {{$id->companyCode ? '' : 'disabled' }}>
I could have also added Quotations for the desired result aswell :
<label for="fname">CompanyCode:</label
<input type="text" id="fname" name="fname" value="{{ $id->CompanyCode }}" disabled>

change date format in input type "text" html

I need to change the date format to 2018-09-23 but now it shows date as 1818-09-23.
<input name="start" id="datepicker1" type="text" value="<?php echo(set_value('start') ? set_value('start') : date('yy-m-d')); ?>" class="form-control">
Is there any possible way to get the date format as 2018-09-23 etc.
Try the following
<input name="start" id="datepicker1" type="text" value="<?php echo(set_value('start') ? set_value('start') : date('Y-m-d')); ?>" class="form-control">
Or in a more logical format:
<input name="start" id="datepicker1" type="text" value="<?php echo(set_value('start') ? set_value('start') : date('m-d-Y')); ?>" class="form-control">

Html required attribute set as not required

I have some code as below:
<label class="control-label col-sm-4" for="datepicker">Date of Birth</label>
<div class="col-sm-8" ><input class="form-control col-sm-10" type="text" id="datepicker" name="datepicker" required="true" value="<?php if(isset($_SESSION['DOB'])) echo $_SESSION['DOB'] ?>"></div>
My issue is that I don't want this "Date of Birth" field to be a required field anymore. How do I set this field as unrequired?
I have tried setting required="false" but this does not work.
Any advice much appreciated, many thanks
Jean-Claude
The required attribute does not take the attribute value. It's just required="true", or required="required", or just setting the
<input type="text" required />
would make it required as well. Just unset the required attribute. If you're trying to unset it after some user action (with javascript) then use the
.removeAttribute("required") function.
<label class="control-label col-sm-4" for="datepicker">Date of Birth</label>
<div class="col-sm-8" ><input class="form-control col-sm-10" type="text" id="datepicker" name="datepicker" value="<?php if(isset($_SESSION['DOB'])) echo $_SESSION['DOB'] ?>"></div>
Avoid using required if you don't need them.
Also the attributes that are not necessary must be avoided.

html form input - multiple answers for each input field

I'm not sure exactly how to word this question, but I'll do my best.
I have a form which collects data about employment history from users. At the moment my form looks like this:
<form name="EmploymentHistory" action="Form E.php" method="post">
<h2>Employment History</h2>
<label>Last/Current employer</label>
<input type='text' name='LastCurrentemployer'>
<hr> <label>Position</label>
<input type='text' name='Position'>
<hr> <label>Date Started</label>
<input type='text' name='DateStarted'>
<hr> <label>Date Finished</label>
<input type='text' name ='DateFinished'>
<hr> <label>Supervised by</label>
<input type='text' name = 'Supervisedby'>
<hr> <label>Contact Details for Boss</label>
<input type='text' name='ContactDetailsForBoss'>
<hr> <button type='button'>Add another job</button> <br>
<hr> <input type="submit" value="Next">
</form>
My problem is that the "Add another job" button does nothing.
How can I enable a user to enter multiple jobs into their employment history so that each job is entered as a new record in my database, but the submit button (next) will only need to be hit once?
I was thinking about trying to set an array to then using arraypush to add each entry, eg:
$pastemployers = array ();
arraypush $pastemployers(POST_['LastCurrentemployer']);
then a loop to add each one as a new record, eg:
for ($x = 0; $x < count(pastemployers); $x++){
echo "<input name='pastemployers" . $x . "' value='" . $pastemployers[$x] . "'> </input>";
I'm sure there's a better way to do this, but I can't find the answer online or work it out. Most of my searches are returning results about checkboxes or multiple submit buttons (not helpful to me). Please help
First of all alter your form as below and use addAnotherJob() to create clone of first span (using jQuery) and change id of each form field.On submitting this form you will get array of employer details.
<form name="EmploymentHistory" action="Form.php" method="post">
<h2>Employment History</h2>
<span class="span_clone">
<label>Last/Current employer</label>
<input type='text' id='LastCurrentemployer_0' name='LastCurrentemployer[]'>
<hr> <label>Position</label>
<input type='text' id='Position_0' name='Position[]'>
<hr> <label>Date Started</label>
<input type='text' id="DateStarted_0" name='DateStarted[]'>
<hr> <label>Date Finished</label>
<input type='text' id='DateFinished_0' name ='DateFinished[]'>
<hr> <label>Supervised by</label>
<input type='text' id='Supervisedby_0' name = 'Supervisedby[]'>
<hr> <label>Contact Details for Boss</label>
<input type='text' id='ContactDetailsForBoss_0' name='ContactDetailsForBoss[]'>
<hr> <button id='add-another-job-0' type='button' onclick= 'addAnotherJob()'>Add another job</button> <br>
</span>
<hr> <input type="submit" value="Next">
</form>
Please refer this link : http://jsfiddle.net/ambiguous/LAECx/

Turn a datalist that gets users from MySQL into Combo Box

I'm using PHP and MySQL to import a list of users into my dropdown box on a form. The user will select their name and move on with the form... my issue at this point is I want to take the drop down box and make a combo box out of it so that the user can quickly type and select there name however I'm not sure of the best way to input that into my php / html code... I'm coming back to this after a couple days away from it so I don't have the code I've tried in the past with a combo box but I could never get it to quite format the names right... what would be the best way to do this?
$datalist = "<select id='soflow' name='name'>";
foreach ($stmt as $row) {
$datalist .= "\r\n<option value='{$row['FULLNAME']}'>{$row['FULLNAME']}</option>";
}
$datalist .= "\r\n</select>";
echo $datalist;
$dbh = null;
?>
</select><br>
<br></br>
<input type="hidden" name="topicid" value="29">
<input type="text" name="email" placeholder="Phone Ext"><br>
<input type="text" name="subject" placeholder="Title of Request"> <br>
<textarea placeholder="Put your message here..." cols="50" rows="4" name="message"> </textarea><br>
<input type="submit" name="submit" value="send" />
Solved it with J Query UI which included a option inside the ui!