简体   繁体   中英

Html form with related fields

I need to develope a html form, but with 2 types of related fields:

  1. Two dropdown related fields: if I choose an option on the first field, the options avaiable on the second field, will change.
  2. About the same, but with sizes (x, y), which must be proportional:

Example

X = 1 cm
Y = 2 cm

or

X = 2cm
Y = 4cm

and so on

Is all this even possible?

Thankk a lot!

This will not be possible with html only. You will need javscript to acomplish that it would look something like this

<!DOCTYPE html>
<html>
<head>
    <script type="text/javascript">

         function changeContent(){
            var x = document.getElementById('x')
            var y = document.getElementById('y')

            y.selectedIndex  = x.selectedIndex; 
         }
     </script>
</head>
<body>
    <select id="x" onchange="changeContent()">
        <option  value="1">1</option>
        <option  value="2">2</option>
    </select>

    <select id="y">
        <option value="1">2</option>
        <option value="2">4</option>
    </select>
</body>
</html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM