I'm trying to get a checkbox to insert today's date into a corresponding textbox, but seem to be having some trouble with getting it to work.
the format of the IDs on the checkboxes and text inputs is id="emailCheckbox[x][y]" and id="emailDate[x][y]" respectively.
what i'm trying to do is pull the [x][y] from the checkbox that was checked (working), and append it to "emailDate" to make "emailDate[x][y]", and update .val()
here's my relative code:
<div> <div class="emailCheckbox">Emailed: <input type="checkbox" id="emailCheckbox[0][1]" name="emailCheckbox[0][1]" value="emailCheckbox[0][1]" /></div> <div class="emailDate">Date: <input type="text" id="emailDate[0][1]" name="emailDate[0][1]" value="" size="15" /></div> </div>
and the javascript:
$(document).ready(function(){
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10){dd='0'+dd} if(mm<10){mm='0'+mm} var today = mm+'/'+dd+'/'+yyyy;
$('div.emailCheckbox :checkbox').change(function(){
if($(this).attr('checked'))
{
var str = $(this).attr('id')
var CustQuote = str.substr(str.indexOf("[")); // Contains [x][y] for customer and quote//
alert(CustQuote + " checked " + today);
alert($("#emailDate" + CustQuote).attr('id'));
}
});
});
well, all i'm getting is "undefined" right for: alert($("#emailDate" + CustQuote).attr('id'));
keep in mind that there is much more information being displayed (also another checkbox that will be doing the same thing for "called[x][y]" and a corresponding text field for "callDate[x][y]" - the parent div has a class of "even" or "odd", and all of the [x][y] values are being filled in with php when the quotes are calculated.
I'm not opposed to changing the div layout if it makes it easier - i'm just kind of on a time crunch, and don't have the time to spend a day trying to get this to work.
..and it's driving me nuts... any thoughts?

New Topic/Question
Reply



MultiQuote


|