Wiring up javascript events and passing parameters -


A little background: I have a page with a table and many checkboxes page asp.net Each line is generated in a checkbox, a checkbox in the header, and in certain cells will be the group of check boxes (you can get multiple picker check boxes).

Works fine with each of these check boxes

  & lt; Td> & Lt; Input type = "checkbox" id = "sellRow1"  

Then there is a little bit of javascript magic in some of your onclick events. "Onclic =" javascript: highlights cry (this, 'alternator style 1'); "/>

There is not much surprises there.

Ok then here is the problem: It works fine, but check box to reflect the states of each other checkbox. For example: the checkbox row in the header replaces the checkbox values, the change in the row checkbox can change the header check box, etc. .

I know what you are thinking: just so much Let's look at the javascript function highlightRow . But if I think how I get the parameter (OK this is easy, but where can I find this on earth? 'Alternaterowstyle1 '?)

So I think the question is: Where do I place those criteria so that I get them with a good cross browser in JS ( & lt; Possible ReadHerring & gt; Custom ET on each checkbox Try putting Ribut, but it was not sure it & lt; / PossibleRedHerring & gt; was the right way to go), I like it too if it does not have to call back on the server, then it is all avoidable.


(BTW sorry that this is a bit malformed / written, I'm extraordinarily tired!)


Update: Okay so in the end I managed to dodge custom properties because it has been seen that there was a hierarchy for the check box. This meant that I was able to trigger the click event of the child checkbox (which means it is called children's click event etc.) Fortunately the flow of this case will never go in the opposite direction, which has an infinite loop (many comments / Documentation to indicate it!)

The only interesting thing with this is click in IE events and the difference in Firefox, Chrome and Safari IE is anything like a click , Where others click the type of buttons, checkboxes, radio, reset or submit elements. I want to use event bubbling in a way that allows to engage the click event in an element that has a group of checkboxes.

Finally went with some of the hacks:

  // IE supports every element in Firefox (also Chrome and Safari) Supports only INPUT Supports elements of type buttons, checkboxes, radios, reset or // https://developer.mozilla.org/en/DOM/element.click // to support this function on allowing Braver to click on all the elements allows for. FireClickEvent (element) {if (element .click) {element.click (); } Else {// We do not have a click on this element, so add your own Var evt = document.createEvent ("MouseEvents"); Evt.initMouseEvent ("click", true, true, window, 0, 0, 0, 0, false, false, false, false, 0, zero); Element.dispatchEvent (evt); }}  

It seems that some extent can be improved, but it does business for now.

It should also accept that this was my first shot on proper Javascript. It's a bit of a scary language (when applying the dome to the app!) Interesting, I'm looking forward to spending a little bit ahead.

You can do this very easily by using jquery. You can do something on checkboxes based on your situation. Define custom attributes and raise the value of the properties of clicks and manipulate the CSS of the rows, check the checkbox as you want. Define an alternative line color for the table using

  $ ("table tr: nth-child (even)" AddClass ("striped"); & gt; Style & gt; Stripped {background color: #ffeff;} & lt; / style & gt;  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -