|
|
|
||||
|
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() |
|
|||||||
| Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
|
Thread Tools |
|
|
#1 |
|
Confirmed User
Join Date: Jun 2004
Location: CZ
Posts: 225
|
javascript...
I have 2 select boxes. Now, how the hell do I change options in the second box when the first one is switched to another option by the user?!!! thanks
__________________
TrafficAdept.com GET BETTER QUALITY TRAFFIC GET PAID MORE TO SELL TRAFFIC by DamageX and STTBoss |
|
|
|
|
|
#2 |
|
Too lazy to set a custom title
Industry Role:
Join Date: Aug 2002
Posts: 55,507
|
not sure about js, would be easy to do in php
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence. ![]() My Cam Feeds Script / Free Templates / Gallery Scraper |
|
|
|
|
|
#3 |
|
Confirmed User
Join Date: Jul 2004
Location: Denmark ICQ: 7880009
Posts: 2,203
|
|
|
|
|
|
|
#4 |
|
Confirmed User
Join Date: Apr 2002
Location: /root/
Posts: 4,997
|
with php it would happen on the server side (the user needs to submit) where with js it happens in the browser no submit needed. |
|
|
|
|
|
#5 |
|
Confirmed User
Join Date: Jul 2004
Location: Denmark ICQ: 7880009
Posts: 2,203
|
|
|
|
|
|
|
#6 |
|
Confirmed User
Join Date: Apr 2002
Location: /root/
Posts: 4,997
|
what does ajax has to do with php ?
|
|
|
|
|
|
#7 |
|
Confirmed User
Join Date: Apr 2003
Location: Loveland, CO
Posts: 5,526
|
Not the greatest solution, but I was bored so, here it is:
Code:
<html>
<head>
<script type="text/javascript">
// hook up your options
slaveArr1 = new Array("Slave option 1","Slave option 2","Slave option 3");
slaveArr2 = new Array("Another option 1","Another option 2","Another option 3");
// do the work
function updateSlave(val)
{
var arr;
if(val != "") // test empty value
{
// set values
if(val == "1")
arr = slaveArr1;
else
arr = slaveArr2;
// reset slave
resetSlave();
// populate options
populateSlave(arr);
}
}
// populates select field
function populateSlave(arr)
{
for(i=0;i<arr.length;i++)
{
o = document.createElement("option");
o.setAttribute("value",arr[i]);
o.appendChild( document.createTextNode( arr[i] ) );
document.getElementById("slave").appendChild(o);
}
}
// kill options in slave select field
function resetSlave()
{
while(document.getElementById("slave").childNodes.length > 0)
document.getElementById("slave").removeChild( document.getElementById("slave").lastChild );
}
</script>
</head>
<body>
<form method="GET" action="">
<p>Select 1:
<select name="master" onchange="updateSlave(this.value)">
<option value=""></option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
</p>
<p>Select 2:
<select name="slave" id="slave"></select>
</p>
</form>
</body>
</html>
__________________
Your post count means nothing. |
|
|
|
|
|
#8 | |
|
Confirmed User
Join Date: Jun 2004
Location: CZ
Posts: 225
|
Quote:
__________________
TrafficAdept.com GET BETTER QUALITY TRAFFIC GET PAID MORE TO SELL TRAFFIC by DamageX and STTBoss |
|
|
|
|
|
|
#9 | |
|
Confirmed User
Join Date: Jun 2004
Location: CZ
Posts: 225
|
Quote:
__________________
TrafficAdept.com GET BETTER QUALITY TRAFFIC GET PAID MORE TO SELL TRAFFIC by DamageX and STTBoss |
|
|
|
|
|
|
#10 |
|
Confirmed User
Join Date: Jul 2004
Location: Denmark ICQ: 7880009
Posts: 2,203
|
|
|
|
|
|
|
#11 | |
|
Confirmed User
Join Date: Jul 2004
Location: Denmark ICQ: 7880009
Posts: 2,203
|
Quote:
|
|
|
|
|