View Full Version : Drop down menu help
13lue
02-12-2008, 09:56 PM
Is there a way to have a drop down list coded with html or css that will change a certain part of the same webpage for example (<script>.....</script> to <script>^^^</script> and refresh the web page? If so what is the coding i could use?
jcdevelopment
02-12-2008, 10:08 PM
Im sorry, im not sure what you mean!?
Andrew Johnson
02-12-2008, 10:15 PM
Perhaps:
<script type="text/javascript">
function change()
{
switch (document.getElementById("select").value)
{
case "1":
document.getElementById("change").innerHTML = "Option 1 has changed this DIV tag's content"
break;
case "2":
document.getElementById("change").innerHTML = "Option 2 has changed this DIV tag's content"
break;
case "3":
document.getElementById("change").innerHTML = "Option 3 has changed this DIV tag's content"
break;
}
}
</script>
<select onchange="change()" id="select">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
<div id="change">
Original Text
</div>
rmedek
02-12-2008, 11:03 PM
Anything that changes the content of the page is the domain of Javascript, not HTML (as Andrew shows). Moving to JS…
13lue
02-13-2008, 02:55 AM
Perhaps:
<script type="text/javascript">
function change()
{
switch (document.getElementById("select").value)
{
case "1":
document.getElementById("change").innerHTML = "Option 1 has changed this DIV tag's content"
break;
case "2":
document.getElementById("change").innerHTML = "Option 2 has changed this DIV tag's content"
break;
case "3":
document.getElementById("change").innerHTML = "Option 3 has changed this DIV tag's content"
break;
}
}
</script>
<select onchange="change()" id="select">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
<div id="change">
Original Text
</div>
Dude you are the best! this was exactly what i was looking for!
13lue
02-14-2008, 12:40 AM
Ok, is there a way to change two different sections instead of just one? For example it would change....
<script>12345</script> TO <script>blahblah</script>
AND
<txtarea>12345</txtarea> TO <txtarea>blahblah</txtarea>
The code that he had given me only allows me to change one at a time. But i really need it do be able to do both. I thought about doing two of these scripts but then the person would have to use both drop down menus to use them. But i really would like if it would run the script and post the script that it used in a textarea. Any ideas that could help me accomplish that?
shedokan
02-20-2008, 09:20 PM
maybe try:
<script type="text/javascript">
function change()
{
switch (document.getElementById("select").value)
{
case "1":
document.getElementById("change").innerHTML = "Option 1 has changed this DIV tag's content"
document.getElementById("change2").innerHTML = "Option 1 has changed this DIV tag's content"
break;
case "2":
document.getElementById("change").innerHTML = "Option 2 has changed this DIV tag's content"
document.getElementById("change2").innerHTML = "Option 2 has changed this DIV tag's content"
break;
case "3":
document.getElementById("change").innerHTML = "Option 3 has changed this DIV tag's content"
document.getElementById("change2").innerHTML = "Option 3 has changed this DIV tag's content"
break;
}
}
</script>
<select onchange="change()" id="select">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
<div id="change">
Original Text
</div>
<div id="change2">
Original Text2
</div>
13lue
02-21-2008, 04:31 AM
lets see if it works if. it does i will <3 you forever!
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.