last day (16 days later) » 

8:36 PM
0
A: How can I modify a date type field based when changing another date type field

Tomanowvar prefix = '_fecha_entrega'; var $inputs = $('input[id*="' + prefix + '"]'); $inputs.each(function (k, v) { if (k % 2 === 0) { var $second = $($inputs.get(k +1)).datepicker({ dateFormat: 'yy-mm-dd' }); var $first = $(v).datepicker({ dateFor...

 
Ok ok, let me replicate it into my project.
I replicate this into my project but isn't working. I updated the code maybe you can give me a hand
 
Did you remove disabled="disabled" from your fields?
 
Yes I did. I added jquery and jquery ui. other thing, is load or ready in jquery?
 
I think it is related to your selectors {{ cuenta }} let me see what I can do for dynamic...
I updated my answer =P
 
This would work for new values?
 
8:36 PM
Yes, any input id that contains _fecha_entrega it will assume the first is start date and second is end date.
 
Hey by the way, Do I need to do this for every loop or just once?
 
Just once after the page is loaded
 
Mmmm I tried but Its not working, by the way, prefix is "_fecha_recibido_daci" I made a mistake when posting the first time. How does variables k , v are initialize, I dont understand that?
 
Then change the variable prefix to _fecha_recibido. If you are satisfied consider selecting my answer as correct.
 
I could make it work Tomanow. What could be the problem? No I post all the code?
 
8:36 PM
I still see '_fecha_recibido_daci' and not '_fecha_recibido' in your post.
 
I updated the post
 
How do I know this time you posted your actual code?
 
Look for --> var prefix = '_fecha_recibido_daci';
 
Since you do not have common prefix in selectors anymore, you need to put a common class on the date fields and modify so that you are selecting them... var prefix = 'myClass'; var $inputs = $(prefix);
 
I tried it but didn´t work. What could be the problem? Is that all that is needed? To sustitute those two lines you said before with var prefix='fecha_recibidio' .... ?
 
8:36 PM
No you need to add a class to the date fields and select them that way since you changed the ids.
 
I added the class="myClass" to the two date fields. I haven't changed the ids as you said. I updated the post in order you can watch the code I have rigth now.
 
ah sorry you have to put a period before the class in the js
var prefix = '.myClass';
typo on me
did that fix it?
 
No problem, Im really appreciating your help. Let me try
No, It didn't work. And I don't know why. Is this correct? var prefix = '.myClass';
var $inputs = $(prefix);

//var prefix = '_fecha_recibido_daci';
//var $inputs = $('input[id*="' + prefix + '"]');
 
8:52 PM
is the code within a loop?
 
This is how it looks

$(document).ready(function(){

var prefix = '.myClass';
var $inputs = $(prefix);

//var prefix = '_fecha_recibido_daci';
//var $inputs = $('input[id*="' + prefix + '"]');

$inputs.each(function (k, v) {

if (k % 2 === 0) {
var $second = $($inputs.get(k +1)).datepicker({
dateFormat: 'yy-mm-dd'
});

var $first = $(v).datepicker({
dateFormat: 'yy-mm-dd',
onSelect: function (dateStr) {
var newDate = $.datepicker.parseDate('yy-mm-dd', dateStr);
newDate.setDate(newDate.getDate() + 14);
No, this is outside the loop
This is all the code for that specific part
<ul>
<li><ul class="garantias" data-prototype="{{ form_widget(form.garantias.vars.prototype)|e }}">
{% set cuenta = 0 %}
{% for garantia in form.garantias %}
<li>

{{ form_row(garantia.garantiaTipo) }}
{{ form_row(garantia.fecha_emision) }}
{{ form_row(garantia.fecha_vencimiento) }}
{{ form_row(garantia.fecha_recibido_daci) }}
{{ form_row(garantia.fecha_entrega) }} {# fecha entrega al proveedor #}


{{ form_row(garantia.empresa_emite_garantia) }}
{{ form_row(garantia.tiempo_de_garantia) }}
{{ form_row(garantia.estado) }}
 
open developer console in browser for your site
type
$inputs;
into console and what does it give you?
also, if that is in your global namespace you might be conflicting with something, best to wrap everything in
$(function($) { /*begin docready and other code in here*/ })(jQuery);
 
oops
just this
(function($) { /*begin docready and other code in here*/ })(jQuery);
 
did you see the the print screen? A function is not define
 
9:10 PM
i cant see the beginning you need to horizontal scroll to the beginning
You have a javascript error that could be breaking everything also...
do you not have jquery-ui included?
wanna do a screen share via join.me ??
 
9:28 PM
ok, lets do it
it says that is not defined
I have jquery ui included
 
9:58 PM
I really appreciated your help. I will keep trying, tell you when its done.
 
says invalid meeting code for join.me
 

  last day (16 days later) »