dmelosi 0 Posted December 11, 2013 Report Share Posted December 11, 2013 Hello, I am using the html5 input type date field in an asp page. I have it saving to the database fine, but how do I display the date as a variable when bringing the date back in the same input type tag? I need to bring it back in the same input tag so the date could be updated if the web user needs to change the original date when adding. Thanks, Dave Quote Link to post Share on other sites
justsomeguy 1,135 Posted December 11, 2013 Report Share Posted December 11, 2013 I would assume that whatever value gets submitted to the server, you would use that same value to write it into the value attribute of the tag. Quote Link to post Share on other sites
dmelosi 0 Posted December 12, 2013 Author Report Share Posted December 12, 2013 Thanks but I have used other pop up calendars to select the date and the value will return from the database when revisiting that page. I am wondering if the new html5 tag shown here (input date) http://www.w3schools.com/html/html5_form_input_types.asp is only used for input and the value cannot be set from the database? <input type="date" name="MessageDatehappen" value="<%=MessageDatehappen%>" /> Quote Link to post Share on other sites
justsomeguy 1,135 Posted December 12, 2013 Report Share Posted December 12, 2013 It works fine for me. If I select a date with that and hit submit, the server shows something like this: Input was received as: bday=2013-12-18 Then if I change the HTML to show this: <input type="date" name="bday" value="2013-12-18"> and submit the change, it renders the date field with that date selected. I'm testing with Opera. Quote Link to post Share on other sites
dmelosi 0 Posted December 12, 2013 Author Report Share Posted December 12, 2013 I am sorry, I have not been very clear. I am wanting to be able to return the variable date as the value that is saved (I hope I uploaded the image ok for the forum) . Quote Link to post Share on other sites
justsomeguy 1,135 Posted December 12, 2013 Report Share Posted December 12, 2013 That's what I showed above, this is what the HTML for that field needs to look like: <input type="date" name="bday" value="2013-12-18"> I don't know if that field requires yyyy-mm-dd or not, but that code definitely works in the TryIt editor, you can try it yourself. I would suggest that you convert the date that you have to yyyy-mm-dd format and use that. Quote Link to post Share on other sites
dmelosi 0 Posted December 12, 2013 Author Report Share Posted December 12, 2013 Thank you for your help, but I cannot get the input date field to display the variable from the database no matter the date format. If I find the answer, I will post it, but am going back to another datepicker. Thanks anyhow. Dave Quote Link to post Share on other sites
dmelosi 0 Posted December 12, 2013 Author Report Share Posted December 12, 2013 I didn't pay enough attention to the - instead of formatting with a / The - does work as you said above. Thank you for your help. Dave Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.