You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Arron Bates <ar...@keyboardmonkey.com> on 2002/03/20 06:50:08 UTC

Re: check box

Sanjay,

It should work for any Html input element. As long as you know the 
resulting input name, you can get at it.
...fun part, is that you can do string concats too if you want to be 
more dynamic...

Indexed example:
document.forms[0]["something["+ i + "].somethingElse"]

Arron.

Sanjay Choudhary wrote:

>Hi Arron,
>
>Thanks for the free tip.
>
>Will this work for elements in nested:iterate also?
>
>-Sanjay
>--- Arron Bates <ar...@keyboardmonkey.com> wrote:
>
>>Sanjay,
>>
>>1) The name of the form is the "name" attribute of
>>your action details 
>>specified in your struts-config.xml file. It  also
>>has to be the 
>>reference name of your bean. So...
>>
>>document.myBean.submit()
>>
>>...would submit the form.
>>
>>2) For this I just have to recommend a great
>>JavaScript reference. The 
>>JavaScript Bible by Danny Goodman.
>>But to kick you off...
>>
>>Great way to reference events from your form items,
>>checkbox for example...
>><input type="checkbox" name="smeg" value="something"
>>
>>onClick="doSomething(this)">
>>
>>...and in your java script to handle this...
>>
>>function doSomething(inElement) {
>>  if (inElement.checked) {
>>    alert("hello");
>>  }
>>}
>>
>>And one more free extra tip...  :)
>>If you're trying to reference an element that has
>>dot notation (nested 
>>properties), you can do so like this...
>>
>>
>document.forms[0]["myProperty.nestedProperty.something"]
>
>>... to disable the above example element ...
>>
>>
>document.forms[0]["myProperty.nestedProperty.something"].disabled
>
>>= true;
>>
>>
>>For more detail and everything else, Danny Goodman
>>has the answer :)
>>
>>Arron.
>>
>>
>>Sanjay Choudhary wrote:
>>
>>>Thanks Michael,
>>>
>>>It worked but it couldn't use 
>>>document.localForm.selectAll.checked;
>>>instead I used document.forms[0].selectAll.checked;
>>>
>>>1. Is there a way to assign a form name with tag
>>>html:form of struts?
>>>
>>>2. I will like to control a data entry on my form
>>>
>>for
>>
>>>certain fields using javascript. E.g. if in
>>>html:checkbox - a user checks then I will allow
>>>
>>enable
>>
>>>html:text field for dataentry else it will be
>>>disabled. I think controlling these functions on
>>>server side will be too expensive. What is the easy
>>>way to refer or pass these controls/fields created
>>>using html:text, html:checkbox etc. in javascripts.
>>>
>>>E.G. if I want the value of field <html:text
>>>property="abc" name=<somebean>/> in the javascript.
>>>or wish to enable or disable this field thru
>>>javascript.
>>>
>>>
>>>All comments appreciated
>>>
>>>-Sanjay
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>--- Michael Skariah <ms...@anshinsoft.com>
>>>
>>wrote:
>>
>>>>Hi Sanjay,
>>>>
>>>>Let me give an example to help you out here. Here
>>>>
>>I
>>
>>>>am assuming that the
>>>>checkboxes (including the master checkbox) are
>>>>present in a table that has
>>>>got an id 'checkTable'. When I say 'master' check
>>>>box I mean the one that
>>>>will help you to trigger the event for
>>>>selecting/de-selecting the other
>>>>child checkboxes.
>>>>
>>>>In the form you can have something like this
>>>><html:checkbox property="selectAll"
>>>>onclick="checkAll()"/>
>>>>for the master checkbox.
>>>>
>>>>And the javascript code could be something like
>>>>
>>this
>>
>>>>function checkAll()
>>>>{
>>>>	var rowCount = checkTable.rows.length;
>>>>	for (var i=1; i < rowCount; i++)
>>>>	{
>>>>	
>>>>
>>checkTable.rows(i).cells(0).childNodes(0).checked
>>
>>>>=
>>>>document.localForm.selectAll.checked;
>>>>	}
>>>>}
>>>>
>>>>See if this help.
>>>>
>>>>Cheers!,
>>>>-Michael.
>>>>
>>>>
>>>>
>>>>-----Original Message-----
>>>>From: Sanjay Choudhary [mailto:java_sc@yahoo.com]
>>>>Sent: Tuesday, March 19, 2002 5:26 PM
>>>>To: Struts Users Mailing List
>>>>Subject: check box
>>>>
>>>>
>>>>In our application, we are showing a list of
>>>>
>>records
>>
>>>>using nested tag. In front of each record we have
>>>>
>>a
>>
>>>>select/check box mapped to a property in a bean.
>>>>
>>>>We wish to provide a functionality to users by
>>>>placing
>>>>a checkbox  at the top row (this is not mapped to
>>>>any
>>>>property in bean) and on click of this check box
>>>>
>>we
>>
>>>>wish to mark all the check boxes shown in the
>>>>
>>list.
>>
>>>>(Exactly like we have in yahoo and hotmail main
>>>>display page, where in an user checks a box and
>>>>everything is selected). I think javascript is a
>>>>
>>way
>>
>>>>to go here.
>>>>
>>>>
>>>>But how do I configure things like html:form name,
>>>>html:checkbox name - also how do I access the
>>>>
>>check
>>
>>>>box for each record displayed to mark them.
>>>>
>>>>Is there a sample project on resource site where
>>>>
>>we
>>
>>>>can find some code to help us out to use
>>>>
>>javascripts
>>
>>>>with struts.
>>>>
>>>>-Sanjay
>>>>
>>>>__________________________________________________
>>>>Do You Yahoo!?
>>>>Yahoo! Sports - live college hoops coverage
>>>>http://sports.yahoo.com/
>>>>
>>>>--
>>>>To unsubscribe, e-mail:
>>>>
>>><ma...@jakarta.apache.org>
>>>
>>>>For additional commands, e-mail:
>>>><ma...@jakarta.apache.org>
>>>>
>>>>
>>>>
>>>>--
>>>>To unsubscribe, e-mail:  
>>>>
>>><ma...@jakarta.apache.org>
>>>
>>>>For additional commands, e-mail:
>>>><ma...@jakarta.apache.org>
>>>>
>>>
>>>__________________________________________________
>>>Do You Yahoo!?
>>>Yahoo! Sports - live college hoops coverage
>>>http://sports.yahoo.com/
>>>
>>>--
>>>To unsubscribe, e-mail:  
>>>
>><ma...@jakarta.apache.org>
>>
>>>For additional commands, e-mail:
>>>
>><ma...@jakarta.apache.org>
>>
>=== message truncated ===
>
>
>__________________________________________________
>Do You Yahoo!?
>Yahoo! Sports - live college hoops coverage
>http://sports.yahoo.com/
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>