Advertisement

Ajax select tab

For Joomla! 5.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
zioleo1987
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Sep 09, 2024 11:24 am

Ajax select tab

Post by zioleo1987 » Mon Sep 09, 2024 11:43 am

Hi,
I try to create a select menu using Ajax, but not work. I use matrix template with Joomla 5.1.2

this result in front end:
Image

My code in article:

Code: Select all

<form action="" method="post"><strong>DETTAGLI SPESE CONTO</strong>
<select id="state">
<option value="NA">Seleziona anno</option>


<?php
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query = "SELECT idanno FROM #__anno";

$db->setQuery($query);
$results = $db->loadAssocList();

if($results != null){
foreach ( $results as $print ){
echo '<option>'.$print['idanno'].'</option>';
}
}
else
{
echo "Error table anno";
}
?>


</select>
</form>
<div id="results"> </div>
Ajax code:

Code: Select all

<script type="text/javascript">
var jQueryRepresentatives = jQuery.noConflict();
jQueryRepresentatives(document.body).on('change','#state',function(){
 jQueryRepresentatives.ajax({
  type: 'GET',
  url: "localhost/progetti/dilerooms/index.php/dashboard",
  success:function(data){
   jQueryRepresentatives('#results').html(data);
  },
  error:function(){
   jQueryRepresentatives('#results').html('<p>error '+jQueryRepresentatives('#state').val()+'</p>');
  }
 }); 
});

</script>
if I selet 2024 year, the result:
Image

because error:function()

Thank you

Advertisement
zioleo1987
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Sep 09, 2024 11:24 am

Re: Ajax select tab

Post by zioleo1987 » Sat Sep 14, 2024 9:49 am

I followed this guide:
https://www.itoctopus.com/how-to-use-jo ... t-com_ajax
but I don't understand where to create the files:
mod_k2_representatives.xml
mod_k2_representatives.php
helper.php

Help me...

Advertisement

Post Reply

Return to “Joomla! 5.x Coding”