Re: PHP quickform with Javascript
| From: | zia mohaddes | Date: | Fri, 16 Jul 2010 05:53:39 +0000 |
| Subject: | Re: PHP quickform with Javascript | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-30656@lists.php.net to get a copy of this message | ||
Hi Mark,
Thank you kindly for your email! I had a somehow stupid question!
I have never used jquery before , so I have the following question:
- I have tried adding $form->addElement( 'text', 'test', 'My
Label', array(
'id' => 'test' ) ); to my php quickform
but do i need to place the
$("#test").click( function() {
alert( 'i was clicked');
});
in a different file or I could execute jquery within the php quickform? if
you have a simple example, that would help allot!
thank you so much!
regards,
On Fri, Mar 12, 2010 at 7:57 PM, Mark Steudel <msteudel@gmail.com> wrote:
> Short answer is yes.
>
> There are a couple of ways you could do this:
>
> 1. Add event directly to element
>
> e.g. <input type="text" onclick="dosomething();" name="test"
> id="test" />
>
> could be done in QuickForm like
>
> $form->addElement( 'text', 'test', 'My Label', array(
> 'onclick' =>
> 'dosomething();', 'id' => 'test' ) );
>
> 2. Use a framework like jquery to add events too your form elements
>
> So to do the above example you'd probably do something like
>
> $form->addElement( 'text', 'test', 'My Label', array(
> 'id' => 'test' ) );
>
> $("#test").click( function() {
> alert( 'i was clicked');
> });
>
> Hope that gets you going.
>
> Mark
> On Fri, Mar 12, 2010 at 1:42 PM, zia mohaddes <zia.simab@gmail.com> wrote:
> > Hello everyone,
> >
> > I am currently using php quickform to create form elements( buttons,
> text,
> > etc...) . However I intend to combine these elements with javascript but
> I
> > am not sure if there php quickform provides the ability of incorporating
> > javascript into the form.
> >
> > I would highly appreciate if anyone can give me some insights as to how I
> > could proceed!
> >
> > Thank you kindly for the help in advance!
> >
> > regards,
> >
> > daniel
> >
>
>
>
> --
>
> -----------------------------------------
> Mark Steudel
> P: 206.375.7244
> msteudel@gmail.com
>
> . : Work : .
> http://www.mindfulinteractive.com
>
> . : Play : .
> http://www.steudel.org/blog
>