473,385 Members | 1,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 >>
****************************
$("formRecherche").addEvent("submit", function(e) {
/**
* Prevent the submit event
*/
new Event(e).stop();

/**
* This empties the log and shows the spinning indicator
*/
$("formRecherche").className = "ajax_loading_01";
/**
* send takes care of encoding and returns the Ajax instance.
* onComplete removes the spinner from the log.
*/
myAjax01 = this.send({
onComplete: function() {
formRechercheMaj (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 >>
****************************
$$("#formRecherche input").each (function (champ)
{
if (champ.type == "checkbox")
{
champ.addEvent ("click", function ()
{
$("formRecherche").fireEvent ("submit");
});
}
});

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

Could someone used tu mootools and ajax help me, please ?
Dec 10 '07 #1
4 4258
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 >>
****************************
$("formRecherche").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
*/
$("formRecherche").className = "ajax_loading_01";
/**
* send takes care of encoding and returns the Ajax instance.
* onComplete removes the spinner from the log.
*/
myAjax01 = this.send({
onComplete: function() {
formRechercheMaj (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 >>
****************************
$$("#formRecherche input").each (function (champ)
{
if (champ.type == "checkbox")
{
champ.addEvent ("click", function ()
{
$("formRecherche").fireEvent ("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 >>
****************************
$("formRecherche").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
*/
$("formRecherche").className = "ajax_loading_01";
/**
* send takes care of encoding and returns the Ajax instance.
* onComplete removes the spinner from the log.
*/
myAjax01 = this.send({
onComplete: function() {
formRechercheMaj (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 >>
****************************
$$("#formRecherche input").each (function (champ)
{
if (champ.type == "checkbox")
{
champ.addEvent ("click", function ()
{
$("formRecherche").fireEvent ("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="formRecherche">
<input name="id_motscles[]" id="motcle_1" value="1" type="checkbox">
<input name="id_motscles[]" id="motcle_2" value="2" type="checkbox">
<input name="id_motscles[]" id="motcle_3" value="3" type="checkbox">
<input name="id_motscles[]" id="motcle_4" value="4" type="checkbox">
<input name="id_motscles[]" id="motcle_5" value="5" type="checkbox">
<input name="id_motscles[]" id="motcle_6" value="6" type="checkbox">
<input name="id_motscles[]" id="motcle_7" value="7" type="checkbox">
<input name="id_motscles[]" id="motcle_8" value="8" type="checkbox">

<input value="Enregistrer" 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
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
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"> ...
2
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
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...
3
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...
1
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
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.