Forums

Problem with dynamic drop downs

chriso0258 10 Jul, 2015
Hello,

I'm having a small problem with the dynamic drop down selections. The dynamic drop down selections are working when a selection is made. The problem I'm having is before any selection is made I want to hide the site selection box (see picture 1 for how I have the event configured). This is not happening. The ajax event is being called even when no selection is being made (see picture 2).

So, my question is, what is wrong with my configuration so that the site selection box will be hidden when no selection has been made.

Picture 1:[attachment=0]dynamic1.jpg[/attachment]

Picture 2: [attachment=1]dynamic2.jpg[/attachment]

Here's the custom code I used in the setup event:
<?php
$options = array();
if ( !$form->data['sites'] || count($form->data['sites']) < 1 ) {
  // no result was found
  $options[] = 'Please select a site';
} else {
foreach ( $form->data['sites'] as $d ) {
    $options[$d['site_id']] =  $d['site'];
    }
}
echo json_encode($options);
?>


The reality is I can live with things the way they are, but if I can tweak it with not a lot of trouble I'd rather learn a little more.

Thanks for your assistance.
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger