Destramic Posted November 14, 2006 Share Posted November 14, 2006 could anyknow tell me why this wouldnt work please?[code]function toggle_checkboxes(form){ var elements = form.elements; for (var i = 0; i < elements.length; i++) { var element = elements[i]; var type = element.type; if (type.toLowerCase() == "checkbox") { element.checked = checked_value; } } if (checked_value) { checked_value = false; } else { checked_value = true; }}[code][/code][/code] Quote Link to comment Share on other sites More sharing options...
Telemachus Posted November 14, 2006 Share Posted November 14, 2006 There must be a problem with checked_value not being defined, but that part would be outside of the function you posted, if it's there - sometimes it slips the mind. Quote Link to comment Share on other sites More sharing options...
fenway Posted November 16, 2006 Share Posted November 16, 2006 Agreed -- it looks like a global variable anyway, which is bad already. Quote Link to comment Share on other sites More sharing options...
Destramic Posted November 18, 2006 Author Share Posted November 18, 2006 does anyone know how i can get it to work? Quote Link to comment Share on other sites More sharing options...
fenway Posted November 19, 2006 Share Posted November 19, 2006 Are you sure checked_value is even defined? Quote Link to comment Share on other sites More sharing options...
Destramic Posted November 20, 2006 Author Share Posted November 20, 2006 check_value gets defined here:if (checked_value) { checked_value = false; } else { checked_value = true; } Quote Link to comment Share on other sites More sharing options...
Telemachus Posted November 20, 2006 Share Posted November 20, 2006 You haven't declared it in any way shape or form though, so when the script tries to evaluate it, inside a function at that, it throws an error. Quote Link to comment Share on other sites More sharing options...
Destramic Posted November 22, 2006 Author Share Posted November 22, 2006 ok no worries ive got it to work now...can anyone help me on how i would do a onclick with just text alone? Quote Link to comment Share on other sites More sharing options...
fenway Posted November 24, 2006 Share Posted November 24, 2006 "with just text alone"? Quote Link to comment Share on other sites More sharing options...
Destramic Posted November 24, 2006 Author Share Posted November 24, 2006 im unable to get this to work with check boxes[code]function toggle_checkboxes(the_form) { for (var i = 0; i <the_form.length; i++) { if (the_form[i].type == 'checkbox') { the_form[i].checked = checkbox_status; } } if (checkbox_status) { checkbox_status = false; } else { checkbox_status = true; }}<span onclick="toggle_checkboxes(this.form);">Check/Uncheck all</span>[/code] Quote Link to comment Share on other sites More sharing options...
fenway Posted November 25, 2006 Share Posted November 25, 2006 I didn't know you could use the_form.length -- don't you mean the_form.elements.length? And again, you're using checkbox_value before it's been checked & set. Quote Link to comment Share on other sites More sharing options...
Destramic Posted November 25, 2006 Author Share Posted November 25, 2006 thank you fenway for your advice...ive done that now..script works fine..but script cannot be activated by text?view here: http://localhost/test.html Quote Link to comment Share on other sites More sharing options...
fenway Posted November 26, 2006 Share Posted November 26, 2006 Again, "activated by text"? Quote Link to comment Share on other sites More sharing options...
Destramic Posted November 26, 2006 Author Share Posted November 26, 2006 well when you click on the text it wont start/run the javascript Quote Link to comment Share on other sites More sharing options...
fenway Posted November 27, 2006 Share Posted November 27, 2006 What text? Quote Link to comment Share on other sites More sharing options...
Destramic Posted November 27, 2006 Author Share Posted November 27, 2006 here: http://rafb.net/paste/results/nRrdOh42.html 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.