Jump to content

Customize calendar


soniyavj7@gmail.com

Recommended Posts

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

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

  • 2 weeks later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...