473,785 Members | 2,612 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mootools, ajax and checkboxes

Hi,

I just made my very first ajax form submitting. This works perfectly
(myAjax01 is a variable external to this function).

*************** *************
Code >>
*************** *************
$("formRecherch e").addEvent("s ubmit", function(e) {
/**
* Prevent the submit event
*/
new Event(e).stop() ;

/**
* This empties the log and shows the spinning indicator
*/
$("formRecherch e").classNam e = "ajax_loading_0 1";
/**
* send takes care of encoding and returns the Ajax instance.
* onComplete removes the spinner from the log.
*/
myAjax01 = this.send({
onComplete: function() {
formRechercheMa j (myAjax01);
}
});
});
*************** *************
<< Code
*************** *************

but i'd like to remove the submit button (visually), and to make the
checkboxes "active" : they should make the same ajax call as if the form
is submitted, each time a checkbox is checked or unchecked, and this
doesn't work (i'm probably not using the event propagation the right
way, but i don't get it).

*************** *************
Code >>
*************** *************
$$("#formRecher che input").each (function (champ)
{
if (champ.type == "checkbox")
{
champ.addEvent ("click", function ()
{
$("formRecherch e").fireEven t ("submit");
});
}
});

*************** *************
<< Code
*************** *************

Could someone used tu mootools and ajax help me, please ?
Dec 10 '07 #1
4 4275
On Dec 10, 6:04 pm, Jean Ceugniet <jean.ceugn...@ gmail.comwrote:
Hi,

I just made my very first ajax form submitting. This works perfectly
(myAjax01 is a variable external to this function).

*************** *************
Code >>
*************** *************
$("formRecherch e").addEvent("s ubmit", function(e) {
/**
* Prevent the submit event
*/
new Event(e).stop() ;
I love how these Prototype-like libraries force you to create a new
object to accomplish the simplest tasks.
>
/**
* This empties the log and shows the spinning indicator
*/
$("formRecherch e").classNam e = "ajax_loading_0 1";
/**
* send takes care of encoding and returns the Ajax instance.
* onComplete removes the spinner from the log.
*/
myAjax01 = this.send({
onComplete: function() {
formRechercheMa j (myAjax01);
}
});});

*************** *************
<< Code
*************** *************

but i'd like to remove the submit button (visually), and to make the
checkboxes "active" : they should make the same ajax call as if the form
is submitted, each time a checkbox is checked or unchecked, and this
doesn't work (i'm probably not using the event propagation the right
way, but i don't get it).

*************** *************
Code >>
*************** *************
$$("#formRecher che input").each (function (champ)
{
if (champ.type == "checkbox")
{
champ.addEvent ("click", function ()
{
$("formRecherch e").fireEven t ("submit");
Unless I miss my guess about MooTools fireEvent method, that won't
submit the form. What you need to do is name your submit listener
function. Then you can call it from here.
});
}

});

*************** *************
<< Code
*************** *************

Could someone used tu mootools and ajax help me, please ?
I know virtually nothing about MooTools (sp?) other than the code was
inspired by Prototype and augments host objects. In other words, it
should be avoided.
Dec 10 '07 #2

Could you explain the "name your submit listener" method in deeper, please ?

TIA

David Mark a écrit :
On Dec 10, 6:04 pm, Jean Ceugniet <jean.ceugn...@ gmail.comwrote:
>Hi,

I just made my very first ajax form submitting. This works perfectly
(myAjax01 is a variable external to this function).

************** **************
Code >>
************** **************
$("formRecherc he").addEvent(" submit", function(e) {
/**
* Prevent the submit event
*/
new Event(e).stop() ;

I love how these Prototype-like libraries force you to create a new
object to accomplish the simplest tasks.
> /**
* This empties the log and shows the spinning indicator
*/
$("formRecherch e").classNam e = "ajax_loading_0 1";
/**
* send takes care of encoding and returns the Ajax instance.
* onComplete removes the spinner from the log.
*/
myAjax01 = this.send({
onComplete: function() {
formRechercheMa j (myAjax01);
}
});});

************** **************
<< Code
************** **************

but i'd like to remove the submit button (visually), and to make the
checkboxes "active" : they should make the same ajax call as if the form
is submitted, each time a checkbox is checked or unchecked, and this
doesn't work (i'm probably not using the event propagation the right
way, but i don't get it).

************** **************
Code >>
************** **************
$$("#formReche rche input").each (function (champ)
{
if (champ.type == "checkbox")
{
champ.addEvent ("click", function ()
{
$("formRecherch e").fireEven t ("submit");

Unless I miss my guess about MooTools fireEvent method, that won't
submit the form. What you need to do is name your submit listener
function. Then you can call it from here.
> });
}

});

************** **************
<< Code
************** **************

Could someone used tu mootools and ajax help me, please ?

I know virtually nothing about MooTools (sp?) other than the code was
inspired by Prototype and augments host objects. In other words, it
should be avoided.
Dec 11 '07 #3
On Dec 11, 5:18 am, Jean Ceugniet <jean.ceugn...@ gmail.comwrote:
Could you explain the "name your submit listener" method in deeper, please ?
Give it a name so you can call it directly in your click listeners.
Looking at your code again, I am unsure as to why the MooTools
fireEvent method is not working for this as it doesn't need to
actually submit the form. In theory it should work. But in reality,
you don't need it to work.
Dec 11 '07 #4
Ok. So, here is my html code. For now, the only way i found to work
around the problem was to click the submit button when the checkboxes
are actually clicked (that triggers the form submit, which is
intercepted ...). If you can show me how to name the click listeners
(i'm not quite used to javascript, and i don't see how to launch the
form submit event when the checkbox click event is triggered : how to
"create" a non-real event and pass it as a parameter ?). Thanks.

*************** ************
Code >>
*************** ************
<form action="code-recherche.php" method="post" id="formRecherc he">
<input name="id_motscl es[]" id="motcle_1" value="1" type="checkbox" >
<input name="id_motscl es[]" id="motcle_2" value="2" type="checkbox" >
<input name="id_motscl es[]" id="motcle_3" value="3" type="checkbox" >
<input name="id_motscl es[]" id="motcle_4" value="4" type="checkbox" >
<input name="id_motscl es[]" id="motcle_5" value="5" type="checkbox" >
<input name="id_motscl es[]" id="motcle_6" value="6" type="checkbox" >
<input name="id_motscl es[]" id="motcle_7" value="7" type="checkbox" >
<input name="id_motscl es[]" id="motcle_8" value="8" type="checkbox" >

<input value="Enregist rer" type="submit">
</form>
*************** ************
<< Code
*************** ************
Dec 11 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
11888
by: Seth Illgard | last post by:
I need one of those. But which one should I pick? Mootools looks great becouse I dont need to use the bad-document-but- still-great scriptaculus. What do you think?
0
5442
by: Dmitry Perets | last post by:
Hello, There is a known problem with TreeView checkboxes in ASP.NET: they can't do AutoPostBack. So I've solved this problem like this: <script language="javascript" type="text/javascript"> function postbackOnCheck() { var o = window.event.srcElement; if (o.tagName == 'INPUT' && o.type == 'checkbox' &&
2
4507
by: manilal prajapati | last post by:
Hi, Using mootools I can implement either vertical or horizontal slider bar . But i want to implement both slider bar at once...
3
4098
by: Piliskner | last post by:
Greetings to all coders. I am new to js and my development is based on using frameworks such as Mootools and libraries such as Wz_jsgraphics. Recently working on my school project I have met with a problem of calling my function to draw something: var jg = new jsGraphics(); function drawArrow() { jg.setColor("#ff0000"); // red jg.drawLine(10, 113, 220, 55); jg.setColor("#0000ff"); // blue
3
2606
sunbin
by: sunbin | last post by:
Hi, I am having in a Trouble when working with dynamic checkboxes (i.e. checkboxes with the same name, e.g. <input type="checkbox" name = "check" value="dynamic integer value">) I have submitted an HTML form (which contains dynamic textboxes and dynamic checkboxes with a Post Button(input type="button")) by using Ajax function. (onClick="return ajaxFunction(document.getElementById('formid'));") In the ajax function, i have collected...
1
1786
by: Piotr Kaleta | last post by:
ekhm ... MOOTOOLS , if you don't know it sorry I won't be pasting docs from mootools.net manuals
4
3786
by: ameshkin | last post by:
Hi Everybody, I'm just now learning javascript and I'm using mootools. What I want to do is to dynamically load a php page into accordian panel 2, depending on which radio button is selected in accordian panel 1. Here is a simplified version of my code. window.addEvent('domready', function() { var accordion = new Accordion('h3.atStart', 'div.atStart', { display: 0, //will open the 1st panel at start
0
10336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8978
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7502
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3655
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.