Ajax dropdown and select one

Twincarb 05 Apr, 2017
Hi,

I have a form with multiple linked dropdowns, an issue I have is when the user selects the first option, the second option is poputlated, if the user wants to select the first option in the second box they have to deselect the first option and reselect it. This then populates section 3 correctly.

What do I need to add to my Ajax event to add "Please Select" to be the first option. I am assuming it's to the $options options array.

<?php
$options = array();
if ( !$form->data['ajax_select_org'] || count($form->data['ajax_select_org']) < 1 ) {
  // no result was found
  $options[] = 'Select Above First';
} else {
  foreach ( $form->data['ajax_select_org'] as $d ) {

    $options[$d['id_org']] = $d['org_name'];
  }
}
echo json_encode($options);
?>


Thanks in advance for your help.

Dave
GreyHead 05 Apr, 2017
Answer
Hi Dave,

Please try
  $options[] = 'Select Above First';
} else {
  $options[] = 'Please Select'; // << add this line
  foreach ( $form->data['ajax_select_org'] as $d ) {

Bob
Twincarb 05 Apr, 2017
Thanks Bob,

That's solved the issue🙂 and makes the data entry flow.

Regards,

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