Forms. Dynamic change of the form's ItemId depending on other page elements

Let's say we need to make a quick order form that depends on the quantity field on the page. 

We can virtually create a modal form button, pass it the desired ItemId, and programmatically call it (and then delete it). 

Markup: 

<div class="s1">
  <input type="text" class="s1-count" value="2">
  <a href="#" class="s1-order">Create order</a>
</div>

Code JS: 

$(function(){
  $(document).delegate('.s1-order', 'click', function(e){
  	e.preventDefault();
    var count = $(this).closest('.s1').find(".s1-count:first").val();
    if(count){
    	var link = $('');
      	$('body').append(link);
        link.trigger('click');
      	setTimeout(function(){ link.remove(); }, 100);
    }
  });
  

As a result, the s1-order button works as if it is a modal form button, in which the quantity from the external s1-count field is entered. 

Falcon Space is a functional web development platform on a narrow stack MS SQL/Bootstrap. Falcon Space Gettting started

SQL-инструмент для создания личных кабинетов на сайте

Суть подхода и история создания Falcon Space

Falcon Space Platform

This is a reduction in the cost of ownership

at the expense of fewer people to support

This is a quick change

while using the program

This is a modern interface

full adaptation for mobile devices

 
Note