javascript - Using JS to auto append new rows based off input selection -


i looking add functionality similar expedia , hotels.com , other similar sites when select number of rooms give option how many adults , children per room. if choose children allow select ages per child well. please see image below example. willing use handlebars or mustache.

for working example visit example.

the first image shows before selecting multiple rooms or children. the first image shows before selecting multiple rooms or children.

the second image shows multiple rooms , children selected. the second image shows multiple rooms , children selected.

what should

  1. create template room
  2. create template children ages.

then after number of rooms selected render many room templates number of rooms.

then repeat same process ages of children.

the piece of data need careful attribute name or id of each of inputs inserted templates because needs match way backend deserialize form.

some frameworks .net mvc have conventions if going post array of objects "name" attribute has like

name = "[x].adults" 

let me know if need code sample further explain said above if follow steps mentioned should able develop form quickly.

---- new ----

find below link simple example of explaining above. keep in mind mockup similar need do:

https://codepen.io/santiagobenitez/pen/zjxmjp


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -