Tuesday 29 January 2019

Previously selected data not reflecting in dropdown list

Hi Guys,I am new to web development and encountered, I am sure, a common rookie mistake.​I have a HTML form that includes 2x dropdown lists. The data is then stored to MongoDB.When looking up the stored data using the same form, all the fields are correctly populated with the data from the DB with the exception of the dropdown lists. These lists display the default value instead of the DB value.​Server Environment: NodeJSHTML written using PUG / JADE​Below is an extract of the form code block. (I have also attached a video depicting the behaviour)mixin ontForm(ont = {}) form(action=`/addOnt/${ont._id || ''}` method="POST") h6.heading-small.text-muted.mb-4 Resident information .pl-lg-4 .row .col-lg-6 .form-group label.form-control-label(for='input-name') Name input#input-name.form-control.form-control-alternative(type='text', placeholder='John', name="resident_name" value=ont.resident_name, required) .col-lg-6 .form-group label.form-control-label(for='input-surname') Surname input#input-name.form-control.form-control-alternative(type='text', placeholder='Appleseed', name="resident_surname" value=ont.resident_surname, required) .col-lg-6 .form-group label.form-control-label(for='input-email') Email address input#input-email.form-control.form-control-alternative(type='email', placeholder='john@example.com' name="resident_email" value=ont.resident_email, required) .col-lg-6 .form-group label.form-control-label(for='input-cell') Cellphone Number input#input-name.form-control.form-control-alternative(type='text', placeholder='0821238888' name="resident_cell" value=ont.resident_cell) hr.my-4 // Address h6.heading-small.text-muted.mb-4 Address Information .pl-lg-4 .row .col-md-4 .form-group label.form-control-label(for='input-address') Complex Name input#input-address.form-control.form-control-alternative(placeholder='Complex Name', type='text', name="complex" value=ont.complex) .col-md-4 .form-group label.form-control-label(for='input-address') Block Name input#input-address.form-control.form-control-alternative(placeholder='Block Name', type='text', name="block_name" value=ont.block_name) .col-md-4 .form-group label.form-control-label(for='input-address') Unit No input#input-address.form-control.form-control-alternative(placeholder='Unit number', type='text', name="unit_no" value=ont.unit_no) .row .col-md-6 .form-group label.form-control-label(for='input-address') Suburb input#input-address.form-control.form-control-alternative(placeholder='Suburb', type='text', name="suburb" value=ont.suburb) .col-lg-6 .form-group label.form-control-label(for='input-city') City input#input-city.form-control.form-control-alternative(type='text', placeholder='City', name="city" value=ont.city) hr.my-4 // Description h6.heading-small.text-muted.mb-4 ONT Information .pl-lg-4 .row .col-lg-6 .form-group label.form-control-label(for='input-manufacturer') ONT Make input#input-complex_name.form-control.form-control-alternative(type='text', placeholder='Zyxel', name="manufacturer" value=ont.manufacturer) .col-lg-6 .form-group label.form-control-label(for='input-model') ONT Model input#input-email.form-control.form-control-alternative(type='text', placeholder='PMG1005-T20A', name="model" value=ont.model) .row .col-lg-6 .form-group label.form-control-label(for='input-ontsn') ONT GPON SN input#input-first-name.form-control.form-control-alternative(type='text', placeholder='5AF69411223344', name="serial_number", value=ont.serial_number required) .col-lg-6 .form-group label.form-control-label(for='input-bwprof') Bandwidth Profile Required? select#input-address.form-control.form-control-alternative(name="package", placeholder="Bandwidth Profile" value=ont.package) option 20Mbps Down | 10Mbps Up option 50Mbps Down | 25Mbps Up option 100Mbps Down | 50Mbps Up option 200Mbps Down | 50Mbps Up option 400Mbps Down | 100Mbps Up option 1000Mbps Down | 100Mbps Up if user.isp_vlan_int === 4080 .row .col-lg-12 .form-group label.form-control-label(for='input-vlan') VLAN select#input-address.form-control.form-control-alternative(name="vlan", placeholder="vlan" value=ont.vlan) option 3 - VI Local LAN option 100 option 200 option 300 option 4080 else .row .col-lg-12 .form-group label.form-control-label(for='input-vlan') input#input-address.form-control.form-control-alternative(type='hidden' name="vlan", placeholder="vlan" value=user.isp_vlan_int) .text-center if ont.serial_number button.btn.btn-primary.mt-4(type='submit') Update ONT else button.btn.btn-primary.mt-4(type='submit') Add ONT ​Any help is appreciated.https://reddit.com/link/al9r57/video/umqy4i3e4id21/player

Submitted January 30, 2019 at 06:05AM by asdutoit

No comments:

Post a Comment