mdupras Posted June 30, 2010 Report Share Posted June 30, 2010 Hi all -- In a previous post, I asked about a block of code that "went bad" on me and stopped working. The code was part of a larger error-checking process in a real estate transactions database that gives alerts if you've selected an incorrect date range (among other checks). Part of the code runs a check when you use the calendar pop-up to fill in the date vs. typing in the box. Here was the original code: function dateClickStart () { document.getElementById('caspioform').Value5_1.focus(); if (document.getElementById) {if(document.getElementById('Value5_1')!= null){ try {v_cal.select(document.getElementById('Value5_1'),'a1','MM/dd/yyyy');return false;} catch (e) {}}}; } function dateClickEnd () { document.getElementById('caspioform').Value5_2.focus(); if (document.getElementById) {if(document.getElementById('Value5_2')!= null){ try {v_cal.select(document.getElementById('Value5_2'),'a2','MM/dd/yyyy');return false;} catch (e) {}}}; } document.getElementById("a1").onclick = dateClickStart; document.getElementById("a2").onclick = dateClickEnd; "a1" and "a2" are references to the calendar pop-up, but when I run Firebug to see how the pop-ups are referenced, it appears to be dynamic -- i.e., with IDs and names like "a1_963361391." When I remove this code block, the rest of the code works, and the error that shows up on this code says "a1 is null" which tells me I'm not referencing the calendar pop-up correctly. Any ideas? Thanks! -- Mike Quote Link to comment Share on other sites More sharing options...
bahar_vm Posted July 1, 2010 Report Share Posted July 1, 2010 Hi Mike, That is right, the calendar element ID is a dynamic one and keeps changing every time page reloads and that is why you can not call the object by its ID. I would suggest to find another event listener to check the dates, for example on form submit call the function. Best, Bahar M. Quote Link to comment Share on other sites More sharing options...
mdupras Posted July 7, 2010 Author Report Share Posted July 7, 2010 OK, thanks Bahar! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.