SPServices Cascade Dropdowns dynamic filter

I have 3 lookup columns.

  1. Site – lookup column to specify type of environment (prod or non-prod)
  2. Operating System – lookup column to specify operating system to be used (linux or windows)
  3. Templates – lookup column that displays list of templates for linux and windows.

Basically, i want to filter the templates base on the type of environment and operating system. i’m using SPServices.SPCascadeDropdowns as solution. the problem is, cascade only works when form is loaded for the first time so in order to select different template whether for linux or windows, form needs to be refreshed. i am new to sharepoint and spservices. appreciate your help on this. below is the code

$  (document).ready(function(){ $  ("select[title='Operating System']").change(function() {     if ($  ("select[title='Operating System']").val() != 2)     {     queryCAML = "<Eq><FieldRef Name='Operating_x0020_System'/><Value Type='Lookup'>Windows</Value></Eq>",     osType()     }     else     {     queryCAML =  "<Eq><FieldRef Name='Operating_x0020_System'/><Value Type='Lookup'>Linux</Value></Eq>",     osType()     } });  


function osType() {     var osValue = $  ("select[title='Operating System'] option:selected").text();             alert (osValue);             alert (queryCAML);             $  (document).ready(function(){             $  ().SPServices.SPCascadeDropdowns({                 relationshipList: "TEST VM Templates",                 relationshipListParentColumn: "Site",                 relationshipListChildColumn: "Template",                 CAMLQuery: queryCAML,                 parentColumn: "Site",                 childColumn: "Template",                 debug: true             })         });  }  

How to set dropdowns field data on Date and Time field?

I am creating a infopath form. In this I have date, Hour, Minutes, Seconds and AM/PM fields, values are as in the dropdowns way. I want to set the date,hour, minutes, seconds and AM/PM. In this I have to set the data on Date and Time fields on the basis of rules but it causing issues me due to date time format. I am doing as following way:

enter image description here

enter image description here

Is there any way that I can set the date value in the date field and time in the time column.

Dependent dropdowns in Magento 2 Frontend

How can I create a pair of dropdowns such that when one is selected, the options for the other one are updated?


<?php $  stateList = $  block->getStates(); ?>      <div>         <h3 class="text-uppercase margin-bottom15"><?php echo __('Pedir una Cita') ?></h3>         <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p>         <div>             <form id="search_cita">                 <div class="form-group states required">                     <select id="state" name="state">                         <option value="">Estado</option>                         <?php foreach($  stateList as $  index): ?>                         <?php  echo '<option value="'.$  index['state'].'">'.$  index['state'].'</option>'; ?>                         <?php endforeach ?>                     </select>                 </div>                 <div class="form-group cities required">                     <div class="control">                         <select name="city" id="city" class="input-text" data-validate="{required:true}">                             <!--option value="">Ciudad</option-->                             </select>                     </div>                 </div>                  <div>                     <button type="submit" class="btn btn-primary"><?php echo __('Buscar un taller') ?></button>                 </div>              </form>         </div>     </div>      <script>         require(['jquery', 'jquery/ui'],function(){                 jQuery(document).on('change','#state',function() {                     var param = 'frame='+jQuery('#state option:selected').attr('value');                     var url = "<?php echo $  block->getStateAction(); ?>";                     //alert(param);                     jQuery.ajax({                         showLoader: true,                         url: url,                         data: param,                         type: "POST",                         dataType: 'json'                     }).done(function (data) {                         jQuery('#city').empty();                         jQuery('#city').append(data);                     });                  });         });     </script> 


<?php namespace Morwi\Citas\Block;  class Display extends \Magento\Framework\View\Element\Template {     protected $  _isScopePrivate;     public function __construct(         \Magento\Framework\View\Element\Template\Context $  context,         \Magento\Directory\Block\Data $  directoryBlock,         array $  data = []     ) {         parent::__construct($  context, $  data);         $  this->directoryBlock = $  directoryBlock;         $  this->_isScopePrivate = true;     }      public function getStateAction() {         return $  this->getUrl('citas/index/display', ['_secure' => true]);      } } 


<?php namespace Morwi\Citas\Controller\Index;  use Magento\Framework\Controller\ResultFactory;   class Display extends \Magento\Framework\App\Action\Action {     protected $  _resultPageFactory;     public function __construct(         \Magento\Framework\App\Action\Context $  context,         \Magento\Framework\View\Result\PageFactory $  resultPageFactory     ){                   parent::__construct($  context);         $  this->_resultPageFactory = $  resultPageFactory;     }      public function execute() {         //*         $  result = $  this->resultFactory->create(ResultFactory::TYPE_JSON);          $  objectManager = \Magento\Framework\App\ObjectManager::getInstance();         $  resource = $  objectManager->get('Magento\Framework\App\ResourceConnection');         $  connection = $  resource->getConnection();          $  html='<option selected="selected" value="">Ciudad</option>';          $  stateName = $  this->getRequest()->getParam('frame');          if($  stateName!='') {              $  tblSL = $  resource->getTableName('store_locator');              $  sql = "SELECT DISTINCT city from " . $  tblSL . " WHERE state LIKE '%". $  stateName ."%'";             $  city = $  connection->fetchAll($  sql);                foreach($  city as $  index){                 $  hmtl= '<option value="'.$  index['city'].'">'.$  index['city'].'</option>';              }         }          return $  result->setData(['success'=>true,'value'=>$  html]);         //*/        }  }  ?> 

But this returns to me

enter image description here

in success I don’t paint the html

Any help would be appreciated.


Magento 2 : Dependent dropdowns in knockout

I am trying to override Magento/Checkout/view/frontend/web/js/view/shipping-address/list.js and Magento/Checkout/view/frontend/web/template/shipping-address/list.html.

I need to create two dropdowns here such that when one is selected, the other one gets it’s values. Like countries and provinces.

The array of values for each dropdown is created in php in config provider.

How can I create these dropdowns in knockout js? Thanks!

Is it valid to let view models populate their own lists for dropdowns in mvc?

I’ve struggled to find any discussion on this.

If you have a simple MVC page for updating a User, and you put a dropdown list on it of Country, you need to populate the dropdown list in the viewmodel. Let’s call it List<Country> countries {get; set;}

If the page is posted, and there’s an error like they forgot to put a User Name in, we redirect them to the page again to try again, at which point we also have to remember to repopulate the model’s List<Country> before redirecting them back to the page.

Three ways to handle this that I know of:

  • In the controller, make a call to the database, e.g. viewModel.Countries = _dataAccess.GetCountries()
  • Store the list in the view bag and not in the model at all e.g. ViewBag.Countries = _dataAccess.GetCountries()
  • Put it into the view model itself, so that List<Country> {get { return _dataAccess.GetCountries(); and thus inject in a DataAccess object.

The third approach is what I am considering because then you don’t need to worry about populating/repopulating the fields in the controller. But I can’t find any evidence via searching that this is an acceptable method, so I fear there is a drawback I am not considering.