Canman2005 Posted October 5, 2009 Share Posted October 5, 2009 Hi all I'm generating a checkbox using var cellRightSel = row.insertCell(4); var sel = document.createElement("input"); sel.className = 'formfield'; sel.name = 'daycare' + iteration; sel.type = "checkbox"; sel.checked = false; cellRightSel.appendChild(sel); if I use sel.onclick = function(){ alert('clicked')} then I can get it to display an alert message when clicked. Is it possible to change that so when clicked, it would dynamically display two blank text fields rather than the alert message? thanks Quote Link to comment Share on other sites More sharing options...
Psycho Posted October 6, 2009 Share Posted October 6, 2009 Yes. Are you wanting to dynamically create those text boxes or do the textboxes already exist but in a hidden state? Personally, I always prefer to create elements in a hidden state than to create them dynamically as you have done above. Whatever the case you can either define the process to create/display those checkboxes when defining that dynamic function sel.onclick = function() { //Insert code to create text boxes } Or you can create the function independently and then assign the onclick to that function function createBoxes() { //Insert code to create text boxes } sel.onclick = createBoxes; 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.