Forums

New Ajax() not defined

Camera 08 Oct, 2012
Hello,
I have a problem.
I'm using Chrnoform V4 with Joomla 2.5 for the dropdpwn nested (country,town)
The code is this :
view source
print?
<script type="text/javascript">
var id_select_to_write = "";//variabile globale della select html da scrivere
 
function PopolaProvince() {
if (document.getElementById("select_regioni").value == "00"){
alert ("Attenzione: Devi selezionare una regione.")
SvuotaSelect('select_comuni');
SvuotaSelect('select_province');
return;
}
document.getElementById("attesa").innerHTML = ' Attendere....';
CosaFare = "PopolaProvince";
SvuotaSelect('select_comuni');
SvuotaSelect('select_province');
id_select_to_write = "select_province";
var id = document.getElementById("select_regioni").value;
var url = "index2.php?option=com_chronocontact&chronoformname=form_ajax&Funzione="+CosaFare+"&id="+id;
new Ajax(url, {
method: 'get',
onComplete: parseResult
}).request();
 
}
 
function PopolaComuni() {
document.getElementById("attesa").innerHTML = ' Attendere....';
CosaFare = "PopolaComuni";
id_select_to_write = "select_comuni";
var id = document.getElementById("select_province").value;
var url = "index2.php?option=com_chronocontact&chronoformname=form_ajax&Funzione="+CosaFare+"&id="+id;
new Ajax(url, {
method: 'get',
onComplete: parseResult
}).request();
}
 
 
function parseResult(request)
{
var msg = request.split('##@##');
document.getElementById("attesa").innerHTML = "";
document.getElementById(id_select_to_write).innerHTML=msg[1];
if(document.all)
{
ie = "<option>opzione</option>" + msg[1];
document.getElementById(id_select_to_write).innerHTML=ie;
document.getElementById(id_select_to_write).outerHTML = document.getElementById(id_select_to_write).outerHTML;
}else{
document.getElementById(id_select_to_write).innerHTML=msg[1];
}
if (CosaFare == "PopolaProvince"){
PopolaComuni();
}
}
 

function SvuotaSelect(id_select){
num_option=document.getElementById(id_select).options.length;
for(a=num_option;a>=0;a--){
document.getElementById(id_select).options[a]=null;
}
}
 
</script>
 
<p><div id="attesa"> </div></p>
 
<div class="form_item">
<div class="form_element cf_dropdown">
<label class="cf_label" style="width: 150px;">Regione</label>
<select onchange="PopolaProvince()" id="select_regioni" size="1" name="select_regioni">
<option value="00">Seleziona una regione...</option>
<?php
$database = &JFactory::getDBO();
$sql = "SELECT * FROM #__regioni";
$database->setQuery($sql);
$results = $database->loadAssocList();

for($i=0, $ct=count($results); $i < $ct; $i++) {
echo "<option value=".$results[$i]['id'].">".$results[$i]['name']."</option> <br />";
}
?>         
</select>
 
</div>
<div class="cfclear"> </div>
</div>
 
<div class="form_item">
<div class="form_element cf_dropdown">
<label class="cf_label" style="width: 150px;">Provincia</label>
<select class="cf_inputbox" id="select_province" size="1" title=""  name="select_province" onchange="PopolaComuni()">
 
 
</select>
 
</div>
<div class="cfclear"> </div>
</div>
 
<div class="form_item">
<div class="form_element cf_dropdown">
<label class="cf_label" style="width: 150px;">Comune</label>
<select class="cf_inputbox" id="select_comuni" size="1" title=""  name="select_comuni">
 
 
</select>
 
</div>
<div class="cfclear"> </div>
</div>
 
<div class="form_item">
<div class="form_element cf_textarea">
<label class="cf_label" style="width: 150px;">Messaggio</label>
<textarea class="cf_inputbox" rows="2" id="text_3" title="" cols="30" name="text_messaggio" ></textarea>
 
</div>
<div class="cfclear"> </div>
</div>

<div class="form_item">
<div class="form_element cf_button">
<input value="Invia Messaggio" name="button_4" type="submit" />
</div>
<div class="cfclear"> </div>
</div>

The user fills the first dropdown but the firebug write that New Ajax is not defined.
Where's the error code? or joomla should be have some plug in

Thanks you
GreyHead 08 Oct, 2012
Hi Camera,

I think that was the code for the older version of MooTools used with Jooma 1.5. The current version uses new Request.HTML({ . . .

Bob
Camera 13 Oct, 2012
Thank's you GreyHead I changed the code but does not worked.

So I bought the Bob's manual (http://greyhead.net/how-to-docs/chronof ... using-ajax) but 😟
This is what I did:
1) Copy/Pasted the "Form HTML" code, inside to the custom html element(2) in the wizard
2) Copy/Pasted the "The Form JavaScript" code, inside the "Load JS" in the "On Load" event of the Advanced Widzard.
3) Created a new event with the name "ajax" and copy/pasted the "The Ajax event Custom Code" code inside a "Custom Code" element.

I think that the problem is the system does not calls the ajax function.
I don't know if I can add the code here and the site is off line.
I have two prblems:
1. The firebug said me that "windows.addEvent is not a function"
2. The second dropdown does not fills....
Help me please...😟
GreyHead 13 Oct, 2012
Hi Camera,

1. The firebug said me that "windows.addEvent is not a function"

Hmm. that's the sign of a JavaScript error that will break the code.

Do you have JQuery installed?

Does the form work if you use the Test Form icon from the Form Editor?

Bob
This topic is locked and no more replies can be posted.