Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2008
    Location
    Pittsburgh, PA
    Posts
    237
    Plugin Contributions
    1

    Default HTML5 Input Field datetime-local ...just for learning sake?

    I'm trying to learn some computer programming and messing around w/ tweaking an super_orders edit screen on v1.3.9 and I can't seem to figure out how the form submission process works for handling a little javascript pop-out window to edit the date w/ a "datetime-local" input field I'm trying to create.

    I've successfully created an edit date field as a raw text input by adding

    Code:
    <?php 
    echo zen_draw_input_field('edit_date', $dates_query->fields['date_purchased']);
    ?>
    ...but when I try to do something like...

    Code:
    <?php
    echo '<input type="datetime-local" id="edit_date" value="' . $date2edit . '>';
    ?>
    ... the date value get sets to all zero's.

    I realize the value submited through datetime-local is in a format that contains a "T" in between the date/time, and I've tried removing it a w/ javascript "OnSubmit" but I can't figure out what it doesn't like or why...

    Thanks,
    b

  2. #2
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: HTML5 Input Field datetime-local ...just for learning sake?

    Have you compared the source code between the two functions?

    Your first should create an input field with a name of edit_date, the second uses an id. They are two different things... if you wanted an I'd for the first, you would have to add it as a parameter to the $parameter variable.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Dec 2008
    Location
    Pittsburgh, PA
    Posts
    237
    Plugin Contributions
    1

    Default Re: HTML5 Input Field datetime-local ...just for learning sake?

    Hey thanks so much! It was because I hadn't put in "name"... "id" was in there because I was trying to edit out the "T" w/ javascript.

    Code:
    echo '<input type="datetime-local" name= "edit_date" value="' . $date2edit . '">';
    ^This works!!!

  4. #4
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,971
    Plugin Contributions
    96

    Default Re: HTML5 Input Field datetime-local ...just for learning sake?

    You could have also used the Zen Cart function to create that input field. The function's declaration looks like:
    Code:
    function zen_draw_input_field($name, $value = '~*~*#', $parameters = '', $required = false, $type = 'text', $reinsert_value = true) {
    $name ... the 'name' of the input field
    $value ... the 'value' of the input field
    $parameters ... any HTML parameters to be added, e.g. an id.
    $type .... the 'type' of the input field, where you can override the default (text)

    ... so, your input field can be created using the Zen Cart functions using the following PHP code:
    Code:
    <?php
    echo zen_draw_input_field ('edit_date', $date2edit, 'id="edit_date"', false, 'datetime-local');
    ?>
    P.S. That function's output will also be a "proper" input tag, which is a self-closing tag ...
    Last edited by lat9; 16 Dec 2016 at 03:27 PM. Reason: Added P.S.

 

 

Similar Threads

  1. Make input field on collectinfo also display the field text as hyperlink
    By jpietrowiak in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 15 Dec 2012, 05:06 AM
  2. How to add a new input field for products customization requests?
    By itsrajk in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 17 Sep 2011, 06:13 PM
  3. How do I add another field for customer to input during order?
    By markiemark in forum Managing Customers and Orders
    Replies: 4
    Last Post: 5 Aug 2008, 11:14 AM
  4. Adding input field for product cost
    By HumDaddy in forum General Questions
    Replies: 0
    Last Post: 4 Dec 2007, 07:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg