Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Show/hide selectbox

Featured Replies

I would like to show a second select box, depending on what value is chosen in the first.

How do I go about this? I have never used javascript or php so if this is a bit of a silly question, please educate me!

 

Thanks in advance!

hello there me too not an expert in javascript but i have managed to found a code for you may be some expert here can help u more

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple Two Col</title>

<link rel="stylesheet" type="text/css" href="style.css" />

</head>
<body>
<script type="text/javascript">
function show(obj) {
no = obj.options[obj.selectedIndex].value;
count = obj.options.length;
for(i=1;i<=count;i++)
document.getElementById('SkiDiv'+i).style.display = 'none';
if(no>0)
document.getElementById('SkiDiv'+no).style.display = 'block';
}
</script>
<script type="text/javascript">
function show2(obj) {
no = obj.options[obj.selectedIndex].value;
count = obj.options.length;
for(i=1;i<=count;i++)
document.getElementById('SkiDi'+i).style.display = 'none';
if(no>0)
document.getElementById('SkiDi'+no).style.display = 'block';
}
</script>


<form name="myForm">
<select onchange="show(this)">
<option value="1">Chronic 177</option>
<option value="2">Chronic 172</option>
<option value="3">Chronic 167</option>
<option value="4">Chronic 157</option>

</select>
</form>



<div id="SkiDiv1" style="display:block">
 <form name="myForm2">
<select onchange="show2(this)">
<option value="1">Chronic 177</option>
<option value="2">Chronic 172</option>
<option value="3">Chronic 167</option>
<option value="4">Chronic 157</option>

</select>
</form>
</div>



<div id="SkiDiv2" style="display:none">tip/waist/tail mm: 110-80-103 <br>
sidecut r. m: 18.0m avg<br>
tip/tail height mm: 56/56 mm <br>
running surface mm: 1384mm <br>
stance back from center mm: 64mm</div>



<div id="SkiDiv3" style="display:none">tip/waist/tail mm: 110-80-103 <br>
sidecut r. m: 16.5m avg<br>
tip/tail height mm: 56/56 mm <br>
running surface mm: 1335mm <br>
stance back from center mm: 62mm</div>

<div id="SkiDiv4" style="display:none">tip/waist/tail mm: 110-80-103 <br>
sidecut r. m: 16.5m avg<br>
tip/tail height mm: 56/56 mm <br>
running surface mm: 1335mm <br>
stance back from center mm: 62mm</div>

<div id="SkiDi1" style="display:none">This is 1</div>	

<div id="SkiDi2" style="display:none">This is 2</div>	

<div id="SkiDi3" style="display:none">This is 3</div>	

<div id="SkiDi4" style="display:none">This is 4</div>	


</body>
</html>

Edited by sash_oo7

  • Author

Thanks sash, that looks like what I need. I will need some help with this though. Which values would I change?

Will this work with showing a large amount of pictures aswell?

I would like to show a second select box, depending on what value is chosen in the first.

How do I go about this? I have never used javascript or php so if this is a bit of a silly question, please educate me!

 

Thanks in advance!

 

 

yes it will work for images too

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
       <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
       <title>Simple Two Col</title>

       <link rel="stylesheet" type="text/css" href="style.css" />

</head>
<body>
<script type="text/javascript">
function show(obj) {
no = obj.options[obj.selectedIndex].value;
count = obj.options.length;
for(i=1;i<=count;i++)
document.getElementById('SkiDiv'+i).style.display = 'none';
if(no>0)
document.getElementById('SkiDiv'+no).style.display = 'block';
}
</script>
<script type="text/javascript">
function show2(obj) {
no = obj.options[obj.selectedIndex].value;
count = obj.options.length;
for(i=1;i<=count;i++)
document.getElementById('SkiDi'+i).style.display = 'none';
if(no>0)
document.getElementById('SkiDi'+no).style.display = 'block';
}
</script>


<form name="myForm">
<select onchange="show(this)">
<option value="1">Chronic 177</option>
<option value="2">Chronic 172</option>
<option value="3">Chronic 167</option>
<option value="4">Chronic 157</option>

</select>
</form>



<div id="SkiDiv1" style="display:block">
 <form name="myForm2">
<select onchange="show2(this)">
<option value="1">Chronic 177</option>
<option value="2">Chronic 172</option>
<option value="3">Chronic 167</option>
<option value="4">Chronic 157</option>

</select>
</form>
</div>



<div id="SkiDiv2" style="display:none">tip/waist/tail mm: 110-80-103 <br>
sidecut r. m: 18.0m avg<br>
tip/tail height mm: 56/56 mm <br>
running surface mm: 1384mm <br>
stance back from center mm: 64mm</div>



<div id="SkiDiv3" style="display:none">tip/waist/tail mm: 110-80-103 <br>
sidecut r. m: 16.5m avg<br>
tip/tail height mm: 56/56 mm <br>
running surface mm: 1335mm <br>
stance back from center mm: 62mm</div>

<div id="SkiDiv4" style="display:none">tip/waist/tail mm: 110-80-103 <br>
sidecut r. m: 16.5m avg<br>
tip/tail height mm: 56/56 mm <br>
running surface mm: 1335mm <br>
stance back from center mm: 62mm</div>

<div id="SkiDi1" style="display:none">This is 1</div>   

<div id="SkiDi2" style="display:none">This is 2</div>   

<div id="SkiDi3" style="display:none">This is 3</div>   

<div id="SkiDi4" style="display:none"><img src="angry.gif" alt="Angry face" /></div>   


</body>
</html>

 

just replace the text within

 

<div id ="SkiDi4"></div> or <div id ="SkiDi3"></div> or<div id ="SkiDiv4"></div> or <div id ="SkiDi3"></div>   

with the image tag

<img src="angry.gif" alt="Angry face" />

please note here you have to use your image path and name

 

 

also you can add more divs as you like

<div id ="SkiDi4"><div id ="SkiDi5"></div> <div id ="SkiDi6"></div> ......and so on 

hope

you can understand

Edited by sash_oo7

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.