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.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 10-17-2006, 07:56 AM   #1
STTBoss
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
STTBoss is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2006, 07:57 AM   #2
fris
Too lazy to set a custom title
 
fris's Avatar
 
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
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2006, 08:16 AM   #3
mortenb
Confirmed User
 
mortenb's Avatar
 
Join Date: Jul 2004
Location: Denmark ICQ: 7880009
Posts: 2,203
http://irt.org/script/form.htm#4

irt.org is a nice site for stuff like this :-)
mortenb is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2006, 08:36 AM   #4
darksoul
Confirmed User
 
darksoul's Avatar
 
Join Date: Apr 2002
Location: /root/
Posts: 4,997
Quote:
Originally Posted by Fris View Post
not sure about js, would be easy to do in php

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.
__________________
1337 5y54|)m1n: 157717888
BM-2cUBw4B2fgiYAfjkE7JvWaJMiUXD96n9tN
Cambooth
darksoul is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2006, 08:37 AM   #5
mortenb
Confirmed User
 
mortenb's Avatar
 
Join Date: Jul 2004
Location: Denmark ICQ: 7880009
Posts: 2,203
Quote:
Originally Posted by darksoul View Post
no it wouldn't.
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.
you could ajax it and use both php and javascript
mortenb is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2006, 08:38 AM   #6
darksoul
Confirmed User
 
darksoul's Avatar
 
Join Date: Apr 2002
Location: /root/
Posts: 4,997
Quote:
Originally Posted by mortenb View Post
you could ajax it and use both php and javascript
what does ajax has to do with php ?
__________________
1337 5y54|)m1n: 157717888
BM-2cUBw4B2fgiYAfjkE7JvWaJMiUXD96n9tN
Cambooth
darksoul is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2006, 08:52 AM   #7
psili
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.
psili is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2006, 08:55 AM   #8
STTBoss
Confirmed User
 
Join Date: Jun 2004
Location: CZ
Posts: 225
Quote:
Originally Posted by mortenb View Post
http://irt.org/script/form.htm#4

irt.org is a nice site for stuff like this :-)
thanks for the link, but it doesn't seem to work... I mean it does load, I click to faq #237 and then on the first link ( http://tech.irt.org/articles/js042/index.htm ) but it doesn't work. Does it open for anyone? If so, can someone copy it here? thanks
__________________
TrafficAdept.com
GET BETTER QUALITY TRAFFIC
GET PAID MORE TO SELL TRAFFIC

by DamageX and STTBoss
STTBoss is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2006, 08:56 AM   #9
STTBoss
Confirmed User
 
Join Date: Jun 2004
Location: CZ
Posts: 225
Quote:
Originally Posted by psili View Post
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>
thanks! I will test it out
__________________
TrafficAdept.com
GET BETTER QUALITY TRAFFIC
GET PAID MORE TO SELL TRAFFIC

by DamageX and STTBoss
STTBoss is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2006, 08:58 AM   #10
mortenb
Confirmed User
 
mortenb's Avatar
 
Join Date: Jul 2004
Location: Denmark ICQ: 7880009
Posts: 2,203
Quote:
Originally Posted by darksoul View Post
what does ajax has to do with php ?
nothing as such.. ajax is just a name for using different technologies together.. php can be a part of ajax if you choose so.
mortenb is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-17-2006, 09:00 AM   #11
mortenb
Confirmed User
 
mortenb's Avatar
 
Join Date: Jul 2004
Location: Denmark ICQ: 7880009
Posts: 2,203
Quote:
Originally Posted by STTBoss View Post
thanks for the link, but it doesn't seem to work... I mean it does load, I click to faq #237 and then on the first link ( http://tech.irt.org/articles/js042/index.htm ) but it doesn't work. Does it open for anyone? If so, can someone copy it here? thanks
Try 1046.. Play around with it a bit.. It's not as difficult as it seems.
mortenb is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.