471,322 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,322 software developers and data experts.

Issue with popup calendar when clicking on dynamically created image

Hi,
Ineed some help from anyone regarding an issue I'm facing.
I've created an image dynamically on clicking a button.
What I inetend to do is when I click on the created image it will popup a calendar.
But the problem is that when I click on the button to create the image it automatically opoup the calendar before creating the image and giving an error "not Implemented" at newimg.onclick.
I'll really appreciate if anyone can help

here is the code I wrote :

Expand|Select|Wrap|Line Numbers
  1. var cellRight = row.insertCell(4);
  2. var el = document.createElement('input');
  3. el.type = 'text';
  4. el.name = 'textField' + button_Id + iteration + 3;
  5. el.id = 'textField' + button_Id + iteration + 3;
  6. el.size = 11;
  7. el.maxlength = 10;
  8. cellRight.appendChild(el);
  9.  
  10. //var cal = new CalendarPopup();
  11. // select cell
  12. var cellRight = row.insertCell(5);
  13. var newa = document.createElement('a');
  14. var newimg = document.createElement('img');
  15. newimg.src = '../images/dynCalendar.gif';
  16. newimg.name = 'anchor' + iteration;
  17. newimg.id = 'anchor' + iteration;
  18. newa.appendChild(newimg);
  19. newa.href = "#"; 
  20. cellRight.appendChild(newa);
  21. newimg.onclick = "cal.select(document.getElementById('textField' + button_Id + iteration + 3),'anchor' + iteration,'MM/dd/yyyy'); return false;";
Aug 6 '07 #1
1 1883
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

Please use CODE tags when posting code in future. Thanks.

Put the calendar call into a function and change the onclick to reference the function, but not call it, e.g.
Expand|Select|Wrap|Line Numbers
  1. newimg.onclick = someFunc;
Currently, what is happening is that you are running your code and assigning the result to the onclick.
Aug 7 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by chotiwallah | last post: by
4 posts views Thread by Ali | last post: by
reply views Thread by R.A.M. | last post: by
1 post views Thread by R.A.M. | last post: by
4 posts views Thread by ShyGuy | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.