I have a form which presents the user a list of checkboxes, some of which have the text label struckthrough some don't depending on initial conditions. This is functioning fine. During the form validation however, I would like to be able to detect which are struckthrough. I can figure out how to check if they're enabled, but whether the label is struckthrough is eluding me. Any ideas?
-
You'll have to use the DOM methods (or jQuery) to look at the parent element of the text to see if its a <del> tag.
Can you provide some sample source so I might be able to elaborate with an example.
Jim : Here is the way I'm currently getting whether any of the checkboxes are checked and also specifically if one in particular is checked. var oSelect=document.getElementById("bldattempts"); for(i=0;iJim : Apologies, wrong code segment posted. please see: if (document.request_submit.Solaris.checked == true) { cnt++; }Darrell Brogdon : So I have to actually agree with Bartek. Using jQuery would make this so much simpler. However, this code might be helpful: var inputs = document.getElementByTagName('input'), len=inputs.length; for (var x=0; xIf the strikeout (your struckthrough) is assigned via a CSS class, you can simple detect the class (since you can already detect enabled/disabled). Else like Darrell mentioned, jQuery will be a great method.
Doing this with jQuery just makes so much more sense then trying to mess around with plain Javascript. Here is what you need, basically:
striked = $("strike"); // As mentioned, you should use `del` .. strike is depreciated $.each(striked, function(i, el) { alert($(el).html() + " is striked through. What do you want to do with it?"); });
Not sure what you want, but that would detect all elements with strike/del on your page. You can also change the search a bit, to restrict it to only within a certain form/div/whatever like so:
striked = $("strike", $("#myform_id"));
Hope that's what you were looking for.
Claudiu : jquery roxmin15
0 comments:
Post a Comment