dmelosi Posted December 11, 2013 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 Link to comment Share on other sites More sharing options...
justsomeguy Posted December 11, 2013 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. Link to comment Share on other sites More sharing options...
dmelosi Posted December 12, 2013 Author 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%>" /> Link to comment Share on other sites More sharing options...
justsomeguy Posted December 12, 2013 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. Link to comment Share on other sites More sharing options...
dmelosi Posted December 12, 2013 Author 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) . Link to comment Share on other sites More sharing options...
justsomeguy Posted December 12, 2013 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. Link to comment Share on other sites More sharing options...
dmelosi Posted December 12, 2013 Author 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 Link to comment Share on other sites More sharing options...
dmelosi Posted December 12, 2013 Author 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 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now