[email protected] Posted September 29, 2015 Share Posted September 29, 2015 we wrote a JavaScript for allocate two dates,for that we customize two text field for take values from date picker. but that work only one condition how its work? {if $product->text_fields|intval} <div class="customizableProductsText"> <h5 class="product-heading-h5">{l s=' Date'}</h5> <ul id="text_fields"> {counter start=0 assign='customizationField'} {foreach from=$customizationFields item='field' name='customizationFields'} {if $field.type == 1} <li class="customizationUploadLine{if $field.required} required{/if}"> <label for ="textField{$customizationField}"> {assign var='key' value='textFields_'|cat:$product->id|cat:'_'|cat:$field.id_customization_field} {if !empty($field.name)} {$field.name} {/if} {if $field.required}<sup>*</sup>{/if} </label> <input type="text" name="textField{$field.id_customization_field}" class="form-control customization_block_input customDatePicker" id="textField{$customizationField}" value="{if isset($textFields.$key)} {$textFields.$key|stripslashes}{/if}" > </li> {counter} {/if} {/foreach} </ul> </div> <div id="demo" style="background:red; width:200px; height:20px;"></div> <button onclick="myFunction()">Click me</button> <script> function myFunction() { var date1 = (document.getElementsByName("textField4")[0].value); var date2 = (document.getElementsByName("textField7")[0].value); var d1 = new Date(document.getElementsByName("textField4")[0].value); var d2 = new Date(document.getElementsByName("textField7")[0].value); var timediff = Math.abs(d2.getTime() - d1.getTime()); var diffd =Math.ceil(timediff/(1000 * 3600 * 24)); if(diffd > 30) { alert("Select dates between 1 to 30!!"); } else { document.getElementById("demo").innerHTML = "pleace select "+diffd+"day from day option"; } } </script> <script> $(document).ready(function() { $('.customDatePicker').datepicker({ dateFormat: 'mm-dd-yy' }).val(); }); </script> {/if} <p id="customizedDatas"> <input type="hidden" name="quantityBackup" id="quantityBackup" value="" /> <input type="hidden" name="submitCustomizedDatas" value="1" /> <button class="button btn btn-default button button-small" name="saveCustomization" onclick="myFunction()"> <span>{l s='Save'}</span> </button> <span id="ajax-loader" class="unvisible"> <img src="{$img_ps_dir}loader.gif" alt="loader" /> </span> </p> </form> {/if} {/foreach} Link to comment Share on other sites More sharing options...
Nishith Nesdiya Posted September 29, 2015 Share Posted September 29, 2015 hi...sorry...but what you need ? please explain more detailsthnaks.. Link to comment Share on other sites More sharing options...
[email protected] Posted September 29, 2015 Share Posted September 29, 2015 The above function works only for 1 product.... Because for each product the text field name is different ie, the one i have highlighted below, So is their any solution for the function to work for all products???? function myFunction() { var date1 = (document.getElementsByName("textField4")[0].value); var date2 = (document.getElementsByName("textField7")[0].value); var d1 = new Date(document.getElementsByName("textField4")[0].value); var d2 = new Date(document.getElementsByName("textField7")[0].value); var timediff = Math.abs(d2.getTime() - d1.getTime()); var diffd =Math.ceil(timediff/(1000 * 3600 * 24)); if(diffd > 30) { alert("Select dates between 1 to 30!!"); } else { document.getElementById("demo").innerHTML = "pleace select "+diffd+"day from day option"; } } Link to comment Share on other sites More sharing options...
Nishith Nesdiya Posted September 29, 2015 Share Posted September 29, 2015 hi.. then you can use some query stick for this get dynamic value $('#your_button_id).click(function (){ $('.your_text_box_class_name).each(function() { var date = $(this).val(); alert(date); }); }); thanks.. Link to comment Share on other sites More sharing options...
[email protected] Posted September 30, 2015 Share Posted September 30, 2015 Thxs for your reply .... Is it possible to customize a text-box in product page..How can we send and receive the corresponding value from the database?? Link to comment Share on other sites More sharing options...
[email protected] Posted October 9, 2015 Share Posted October 9, 2015 Can we remove "header_shopversion" from prestashop admin part???? 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