#JS converter app doubt

1 messages · Page 1 of 1 (latest)

restive sorrel
#

I have attached some images , without making separate html unit for volume and mass , in html how should i , showcase different units on different section ? Is there any way , other than creating 3 html elements , grabbing there Id's in JS and then making manual changes?

eager garnet
#

Hi @restive sorrel I would say yes, you will need to create 3 separte parts in the HTML to display the outouts from your conversion. I did something like this

            <div>
                <h2>Length (Meter/Feet)</h2>
                <p id="length-text">0 meters = 0 feet | 0 feet = 0 meter</p>
            </div>
            <div>
                <h2>Volume (Liters/Gallons)</h2>
                <p id="vol-text">0 litres = 0 gallons | 0 gallons = 0 litres</p>
            </div>
            <div>
                <h2>Mass (Kilograms/Pounds)</h2>
                <p id="mass-text">0 kilos = 0 
pounds | 0 pounds = 0 kilos</p>
            </div>
#

Then I created a function which took the input value and converted it in JS, using the HTML id's to alter the innerHTML

#

Hopefully that helps a little