Re: PHP quickform with Javascript
| From: | Mark Steudel | Date: | Sat, 17 Jul 2010 02:23:10 +0000 |
| Subject: | Re: PHP quickform with Javascript | ||
| References: | 1 2 3 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-30657@lists.php.net to get a copy of this message | ||
I would create a separate JS file and include it in the head of your html file:
<script language="javascript" type="text/javascript"
src="/path/to/jqueryfile.js"></script>
<script language="javascript" type="text/javascript"
src="yourscript.js"></script>
Then in yourscript.js file, I would probably do something like:
$(document).ready( function() {
$("#test").click( function() {
alert( 'i was clicked' );
})
})
On Fri, Jul 16, 2010 at 1:53 AM, zia mohaddes <zia.simab@gmail.com> wrote:
> 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
>
>
--
-----------------------------------------
Mark Steudel
P: 425.298.7244
F: 206.260.3021
msteudel@gmail.com
. : Work : .
http://www.mindfulinteractive.com
. : Play : .
http://www.steudel.org/blog