Quantcast
Channel: Joomla! Forum - community, help and support
Viewing all articles
Browse latest Browse all 2090

Joomla! 5.x Coding • Ajax select tab

$
0
0
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:

<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:

<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

Statistics: Posted by zioleo1987 — Mon Sep 09, 2024 11:43 am



Viewing all articles
Browse latest Browse all 2090

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>