HTML5 input type show only years - html

Maybe this question already asked but that not solve my problem.
This is my query in input box i want to show only years like this
Thanks in advance
Note: Already this qustions asked but it not solve my issue

How to Resolve input year only <input date="year">
You can use this snippet.
PHP Version:
<select class="form-control" name="startyear">
<?php
for ($year = (int)date('Y'); 1900 <= $year; $year--): ?>
<option value="<?=$year;?>"><?=$year;?></option>
<?php endfor; ?>
</select>
JavaScript Version:
<select name="yearpicker" id="yearpicker"></select>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript">
let startYear = 1800;
let endYear = new Date().getFullYear();
for (i = endYear; i > startYear; i--)
{
$('#yearpicker').append($('<option />').val(i).html(i));
}
</script>

Please try select and show year only. And guide is here

I would like to make a small correction to Rhalp's answer for efficiency sake. Don't initialize the object 219 times. In general it's much less work on the browser engine if you get the member before you loop over it.
<select name="yearpicker" id="yearpicker"></select>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>
<script type="text/javascript">
let startYear = 1800;
let endYear = new Date().getFullYear();
for (i = endYear; i > startYear; i--)
{
$('#yearpicker').append($('<option />').val(i).html(i));
}
</script>

Related

Is it possible to disabel all HTML-Elements of a Form during a transaction is running

e.g. buttons..
<body disabled>
does not work
Thank you
The following script will select all descendants of your form element. You can use any selector to get the desired set of elements and apply this script to disable them all.
<script >
var form_elem=document.querySelectorAll("form *");
for(var i of form_elem){
i.setAttribute("disabled", true);
}
</script>
I would use javascript:
<script language='Javascript'>
document.getElementById("this_is_the_submitbutton").disabled = true;
</script>
Your submitbutton needs to have have the id='this_is_the_submitbutton'

set a $_GET value when option is selected

How would I set filter_branch=true and filter_branch_val=sony via $_GET when an option is selected?
<select name="filter_brand">
<option>Sony</option>
<option>LG</option>
</select>
So I have something like http://mypage.com/index.php?filter_branch=true&filter_branch_val=sony to be used for sql query filter.
If java script function will work for you . please try this code
HTML
<select name="filter_brand" onchange="sendFilter(this.value)">
<option>Sony</option>
<option>Lg</option>
<option>Samsung</option>
</select>
Javscript
<script type="text/javascript">
function sendFilter(vaa)
{
console.log(vaa);
window.location.href = 'product.php?
filter_branch_val='+vaa+'&filter_branch=true';
}
</script>
You can use jQuery for this. I have tested it and it is working.
Add this:
<head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> </head>
HTML
<select id="myselect" name="filter_brand" onchange="javascript:goToURL()">
<option>No selection *</option>
<option>Sony</option>
<option>LG</option>
</select>
SCRIPT
<script>
function goToURL(url){
var option = $( "#myselect option:selected" ).text();
var yoururl = "http://www.example.com/";
var url = yoururl+ "?page="+ option;
window.location.replace(url);
}
</script>
Try this and come back to me.
I used This and This as reference.

Aaccessing button properties from another jsp file

I have disabled button in a.html and some xyz button in b.html.
When the xyz button in b.html is clicked then the disabled button in a.html should get enabled.
I have been trying this for two days but am not getting anywhere. Can you help me?
If it's just plain html pages, you can use jQuery/ JavaScript to do this. Here is a simple example:
a.html:
<body>
<input id="aButton" type="button" value="A Button">
<script type="text/javascript">
$(document).ready(function() {
var enableAButton=getUrlParameter("enable");
if(enableAButton == "true"){
$('#aButton').prop('disabled', false);
}else{
$('#aButton').prop('disabled', true);//disabled by default
}
});
function getUrlParameter(sParam)
{
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++)
{
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam)
{
return sParameterName[1];
}
}
}
</script>
</body>
b.html:
<body>
<input id="bButton" type="button" value="B Button">
<script type="text/javascript">
$("#bButton").click(function(){
window.location.href="a.html?enable=true"
});
</script>
</body>
If both are different files without any relation you cant disable it directly. instead you can maintain a flag variable in the database of the student to track the info . enable and dis-able based on its value.

Turning On HTML5 Native Form Validation For WordPress Comments?

On line 2022 in wp-includes/comment-template.php WordPress 3.7.1 sets the form attribute to 'novalidate.' I don't see a hook to change that.
How do I convince WordPress to leave that attribute off so that native HTML5 form validation is active?
Bob
There's no filter to modify that attribute. You could remove it with jQuery:
$("#commentform").removeAttr("novalidate");
You can remove novalidate attribute with this simple Javascript:
<script type="text/javascript">
var commentForm = document.getElementById('commentform');
commentForm.removeAttribute('novalidate');
</script>
No jQuery needed.
You can include the following code to run script just on posts:
footer.php
<?php if( is_singular() ) : ?>
<script type="text/javascript">
var commentForm = document.getElementById('commentform');
commentForm.removeAttribute('novalidate');
</script>
<?php endif; ?>
Use this function rather than comment_form()
function validate_comment_form(){
ob_start();
comment_form();
echo str_replace('novalidate','data-toggle="validator" ',ob_get_clean());
}

How to set a default date in html? [duplicate]

This question already has answers here:
How to set input type date's default value to today?
(43 answers)
Closed 9 years ago.
I am editing a HTML file and there is one attribute application deadline. How can I set a default value to the application deadline to one year after today in the html code? Thanks for helping
Below is the original HTML code
<div class="field" >
Application Deadline:
<input type="date" id="id_application_deadline" name="application_deadline">
</div>>
This is not possible without java script, Try this
<script language="javascript">
<!--
today = new Date();
document.write("", today.getDate(),"/",today.getMonth()+1,"/",today.getYear());
//-->
</script>
Just set the desired date as value attribute:
<input type="date" id="id_application_deadline" name="application_deadline" value="2013-05-29">
If you're only using html, without javascript, there won't be a way to calculate the 1 year offset i think.
try this
<head>
<script type="text/javascript">
function onload()
{
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1;
var yyyy = today.getFullYear();
yyyy = parseInt(yyyy) + 1;
today = dd+'-'+mm+'-'+yyyy;
document.getElementById("id_application_deadline").value = today;
}
</script>
</head>
<body onload="onload()">
<div class="field" >
Application Deadline:
<input type="text" id="id_application_deadline" name="application_deadline">
</div>
</body>