Hi there can you help me solving this,
I have this code here
<div>
<div>
<input type="text" name="" tabindex="0" styling="[object Object]"
placeholder="YYYY/MM/DD" aria-label="date" aria-invalid="false"
valid="1" class="needsclick TextInput__FormStyledTextInput-sc-1o6de9f-0
fsIKy kl-private-reset-css-Xuajs1">
</div>
</div>
<div>
<div>
<input type="text" name="" tabindex="0" styling="[object Object]"
placeholder="YYYY/MM/DD" aria-label="date" aria-invalid="false"
valid="1" class="needsclick TextInput__FormStyledTextInput-sc-1o6de9f-0
fsIKy kl-private-reset-css-Xuajs1">
</div>
</div>
How can i give the input value today’s date, with pure javascript, i cant add manually and can’t add other classes name or id’s because its automatically generated.
Thanks,
Edited,
The script i want to include is in a shopify theme, and the inputs are on a pop-up, maybe this will help you more
5
Answers
This should help:
You can use
getElementsByClassName()
method to get the elements with class "test" and then use "Date()" to pass the date.EDIT
If you only want a single input to display the date:
var now = new Date();
document.getElementsByClassName("test")[0].value = now;
document.getElementsByClassName("test")[1].value = now;
Here you go :