I read through Greyheads Ajax double drop-down tutorials and haven't been able to get my Javascript to respond to domEvents. I used the methods in Greyheads - double drop-down with Ajax tutorial for my form with no luck.
Form HTML:
I am able to populate the 1st drop down but nothing happens when I select a value.
Form Javascript:
Form Extra Code:
I can't see the problem, any help is appreciated.
Form HTML:
<div class="form_item">
<div class="form_element cf_text"> <span class="cf_text">Request Record</span> </div>
<div class="cfclear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_dropdown">
<label class="cf_label" style="width: 150px;">Week Ending</label>
<select class="cf_inputbox" id="myweek" size="1" title="" name="myweek">
<option value="">==??==</option>
<?php
$db =& JFactory::getDBO();
$query = "Select DISTINCT `weekending` FROM #__chronoforms_corpreporting;";
$db->setQuery($query);
$count = $db->loadAssocList();
$i = 1;
$thiWeekending = $count[$i]['weekending'];
while ($thisWeekending != "" or $thisWeekending != null ) { $thisWeekending = $count[$i]['weekending']; echo "<option value='".$thisWeekending."'>" . $thisWeekending . "</option>"; $i++; }
?>
</select>
</div>
<div class="cfclear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_dropdown">
<label class="cf_label" style="width: 150px;">Store Name </label>
<span id='ajax_getuser' style='color:#444;'>Select Store Name</span>
<span id='progress_getuser' style='visibility:hidden;'>Searching...</span>
</div>
<div class="cfclear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_button">
<input value="next" name="next" type="submit" />
</div>
<div class="cfclear"> </div>
</div>
I am able to populate the 1st drop down but nothing happens when I select a value.
Form Javascript:
window.addEvent('domready', function()
{
$('myweek').addEvent('change', function() {
var a = $('myweek').value;
if ( a != null && a != '' ) {
getUser(a);
} else {
$('ajax_getuser').setHTML("<span id='ajax_getuser' > No Record Found</span>")
}
});
});
function getUser(a){
var url="index.php?option=com_chronocontact&chronoformname=requestInfo&task=extra&format=raw";
new Ajax(url, {
method: 'get',
onRequest: functoin(){
$('progress_getuser').setStyle('visibility', 'visible');
},
onComplete: function(){
$('progress_getuser').setStyle('visibility', 'hidden');
},
update: $('ajax_getuser'),
data: 'we='+a
}).request();
};
Form Extra Code:
<?php
$week =& JRequest::getString('we', '', 'get);
if ($week)
{
$db =& JFactory::getDBO();
$query = "Select DISTINCT `user` AS `id`, `user` FROM #__chronoforms_corpreporting WHERE `weekending` = '$week';";
$db->setQuery($query);
$data = $db->loadAssocList();
if ( count($data) ) {
$m = new stdClass();
$m->id = 0;
$m$->user = '==?==';
$data = array_merge(array($m), $data);
$return = JHTML::_('select.genericlist', $data, 'user', 'class="inputbox required select" size="1" ', 'id', 'user', 0);
} else {
$return = "Sorry, user record not found";
}
} else {
$return = "Sorry, unknown error";
}
echo $return;
?>
I can't see the problem, any help is appreciated.
Hi someguy2k,
Do you get any JavaScript errors on the page?
Please post a link to the form so we can take a quick look.
Bob
Do you get any JavaScript errors on the page?
Please post a link to the form so we can take a quick look.
Bob
Thanks for pointing out the typo Bob, I'm now calling the function and made sure to add jQuery.noConflict(); to my JS box and now get the following.
Parse error: syntax error, unexpected T_VARIABLE in /home/nuemind/public_html/cheeburgercorp.com/corpreporting/components/com_chronocontact/libraries/chronoform.php(516) : eval()'d code on line 6
extradeCode: Line #6
$query = "Select DISTINCT `user` AS `id`, `user` FROM #__chronoforms_corpreporting WHERE `weekending` = '$week';";
-joel
Parse error: syntax error, unexpected T_VARIABLE in /home/nuemind/public_html/cheeburgercorp.com/corpreporting/components/com_chronocontact/libraries/chronoform.php(516) : eval()'d code on line 6
extradeCode: Line #6
$query = "Select DISTINCT `user` AS `id`, `user` FROM #__chronoforms_corpreporting WHERE `weekending` = '$week';";
-joel
This topic is locked and no more replies can be posted.