Jump to content
Sign in to follow this  
dmelosi

input type date html5 value

Recommended Posts

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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%>" />

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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)

.inputdate.jpg

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...