If all else fails you guys should go look at the source for
http://tacos.sourceforge.net. Inside you will find all manner of scripting
Forms/For loops/etc that may show you some better examples of how this can
be done.

jesse

On 1/24/06, Jesse Kuhnert <[EMAIL PROTECTED]> wrote:
>
> Yeah you've sort of run into a chicken and egg problem. The unique id of
> your submit component can't actually be determined until after it's been
> rendered (at least not through normal means), so your goal should be to find
> a way to create your javascript ~after~ these guys have been rendered.
>
> You could achieve this goal very easily by using the incredibly useful
> Script component, 
> http://jakarta.apache.org/tapestry/tapestry/ComponentReference/Script.html
> .
>
> You want to more or less use the last example as your reference. Be sure
> to place your @Script at the END of the form, not before your fields..
>
> Then all you have to do is use friendly ognl notation to pass whatever
> parameters you want into your script. In this instance, you could either
> pass your input component into the script, ie
>
> <span jwcid="@Script" script="/com/mycorp/scripts/ToggleInput.script"
> input="ognl:components.test"  />
>
> and then call "test.clientId" from within your script, OR you could just
> pass the id's in, which is what you probably want ultimately anyways:
>
> <span jwcid="@Script" script="/com/mycorp/scripts/ToggleInput.script"
> input="ognl:components.test.clientId" />
>
> Then your toggle method becomes much easier:
>
> <input-symbol key="input" required="yes"/>
>
> <script>
>
>
> <body>
> function toggleInput(chk) {
>     var inputField = document.getElementById(${inputId});
>     if(!inputField) return; //might not exist
>     inputField.disabled=!chk.checked;
> }
> </body>
> </script>
>
>
> Now your checkbox javascript can look like:
>
> <input type="checkbox" name="checkbox" value="checkbox"
> onClick="javascript:toggleInput(this);">
>
> Of course none of this would have been necessary if your checkbox were
> rendered ~after~ the submit intput, but that's not always possible...
>
> Hope that helps. (It better ;) )
>
> j
> On 1/24/06, Jorge Quiroga < [EMAIL PROTECTED] > wrote:
> >
> > Hi Jesse:
> >
> > Firstly thanks for your time and tip, I resolve partially a problem with
> >
> > java script with a component and I have to re-do an Id, calculate the js
> > function into the .script and into the .java and generate a lot of js
> > that can be replaced for only one function and passing two parameters, a
> >
> > button and a Checkbox. The funtionality is achieve with this js function
> >
> > <script language="javascript">
> >    function enableButton(btn, chk)
> >    {
> >       btn.disabled=!chk.checked;
> >    }
> > </script>
> > </head>
> > <body>
> > <form name="form1" method="post" action="">
> >    <input type="checkbox" name="checkbox" value="checkbox"
> > onClick="enableButton(test, this)">
> >
> >    <input type="button" id="test" name="Submit" value="Send">
> > </form>
> >
> > The problem is pass the parameters from tapestry, do you know how to
> > achieve this?
> >
> > Thanks
> >
> > JQ
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>

Reply via email to