Scripting Question
Hi there guys.
I have a query about whether it is possible to do something. I want to create a script where I get someone to select something from a drop-down list and then you are able to select something else from another drop-down, which then produces a random result.
I can find a script for the drop-down thing and I know of a script that allows you to display random bits of text or images, but I am not sure how I could combine them. You see there is 39 items in the first drop-down, which when one could be selected could bring up a maximum of 5 in the next drop-down and then it randomly displays the result according to what the drop-down says.
For instance,
In drop-down one I select, fruit.
In drop-down two I then select, oranges.
Then this next script gives me a random type of orange.
Hope you can help thanks!
What would you suggest I used to create such a script (language wise)?
Abhishek Reddy posted this at 01:57 — 20th April 2003.
He has: 3,348 posts
Joined: Jul 2001
Javascript, definitely. Do you have a set of images for each possible choice in the second drop-down?
Timewell posted this at 10:16 — 20th April 2003.
They have: 344 posts
Joined: Jun 2002
No. It will probably be a list of text.
Abhishek Reddy posted this at 10:27 — 20th April 2003.
He has: 3,348 posts
Joined: Jul 2001
I don't know where I got the idea of images. I have a photographic memory, I suppose - oranges and all.
Anyway, in case it might save time, can you post the scripts you do have? Might be easier to combine them than to write one ground up.
Timewell posted this at 19:51 — 20th April 2003.
They have: 344 posts
Joined: Jun 2002
The drop-down script is:
<tr>
<td align="centre"><font color="#ffffff">Field Drop-down</font></td>
<td align="centre">
<select name="COUNTRY" onChange=ChangeDetail(this.form)>
<option value="0" selected>Thing</option>
<option value="TEST">Test</option>
</select>
</td>
</tr>
<tr>
<td align="centre"><font color="#ffffff">County/State *</font></td>
<td align="centre">
<div id=newDetail1>
<select name=STATE>
<option value="0" selected>--(Select a State/Province)--</option>
</select>
</div>
</td>
</tr>
IE = (document.all)?1:0;
NS = (document.layers)?1:0;
detail0 = '';
detailUS='<option value="Alabama">Alabama</option><option value="Alaska">Alaska</option><option value="Arizona">Arizona</option><option value="Arkansas">Arkansas</option><option value="California">California</option><option value="Colorado">Colorado</option><option value="Connecticut">Connecticut</option><option value="Delaware">Delaware</option><option value="Florida">Florida</option><option value="Georgia">Georgia</option><option value="Hawaii">Hawaii</option><option value="Idaho">Idaho</option><option value="Illinois">Illinois</option><option value="Indiana">Indiana</option><option value="Iowa">Iowa</option><option value="Kansas">Kansas</option><option value="Kentucky">Kentucky</option><option value="Louisiana">Louisiana</option><option value="Maine">Maine</option><option value="Maryland">Maryland</option><option value="Massachusetts">Massachusetts</option><option value="Michigan">Michigan</option><option value="Minnesota">Minnesota</option><option value="Mississippi">Mississippi</option><option value="Missouri">Missouri</option><option value="Montana">Montana</option><option value="Nebraska">Nebraska</option><option value="Nevada">Nevada</option><option value="New Hampshire">New Hampshire</option><option value="New Jersey">New Jersey</option><option value="New Mexico">New Mexico</option><option value="New York">New York</option><option value="North Carolina">North Carolina</option><option value="North Dakota">North Dakota</option><option value="Ohio">Ohio</option><option value="Oklahoma">Oklahoma</option><option value="Oregon">Oregon</option><option value="Pennsylvania">Pennsylvania</option><option value="Rhode Island">Rhode Island</option><option value="South Carolina">South Carolina</option><option value="South Dakota">South Dakota</option><option value="Tennessee">Tennessee</option><option value="Texas">Texas</option><option value="Utah">Utah</option><option value="Vermont">Vermont</option><option value="Virginia">Virginia</option><option value="Washington">Washington</option><option value="Washington D.C.">Washington D C </option><option value="West Virginia">West Virginia</option><option value="Wisconsin">Wisconsin</option><option value="Wyoming">Wyoming</option>';
detailCA='<option value="Alberta">Alberta</option><option value="British Columbia">British Columbia</option><option value="Manitoba">Manitoba</option><option value="New Brunswick">New Brunswick</option><option value="Newfoundland">Newfoundland</option><option value="Nunavut">Nunavut</option><option value="Nova Scotia">Nova Scotia</option><option value="Nunavut">Nunavut</option><option value="Ontario">Ontario</option><option value="Prince Edward Island">Prince Edward Island</option><option value="Quebec">Quebec</option><option value="Saskatchewan">Saskatchewan</option><option value="Yukon">Yukon</option>';
function ChangeDetail(pos) {
pos = pos.COUNTRY.options[pos.COUNTRY.selectedIndex].value;
temp = '<select name="STATE">"<option value="0">--(All details)--</option>"' + eval("detail" + pos) + '</select>';
if(IE){ newDetail1.innerHTML=(temp)}
else if(NS){
document.newDetail1.document.write(temp)
document.newDetail1.document.close()
document.write("abcdef");
}
}
</script>
<noscript></noscript>
Then the random script thing is:
<?
include ("config.php");
srand((double)microtime()*1000000);
$randomnumber = rand(0,$howmany);
if ($randomnumber== "0") {
include ("ads/ad1.inc");
}
if ($randomnumber== "1") {
include ("ads/ad2.inc");
}
if ($randomnumber== "2") {
include ("ads/ad3.inc");
}
if ($randomnumber== "3") {
include ("ads/ad4.inc");
}
if ($randomnumber== "4") {
include ("ads/ad5.inc");
}
if ($randomnumber== "5") {
include ("ads/ad6.inc");
}
if ($randomnumber== "6") {
include ("ads/ad7.inc");
}
if ($randomnumber== "7") {
include ("ads/ad8.inc");
}
if ($randomnumber== "8") {
include ("ads/ad9.inc");
}
if ($randomnumber== "9") {
include ("ads/ad10.inc");
}
if ($randomnumber== "10") {
include ("ads/ad11.inc");
}
if ($randomnumber== "11") {
include ("ads/ad12.inc");
}
if ($randomnumber== "12") {
include ("ads/ad13.inc");
}
if ($randomnumber== "13") {
include ("ads/ad14.inc");
}
if ($randomnumber== "14") {
include ("ads/ad15.inc");
}
if ($randomnumber== "15") {
include ("ads/ad16.inc");
}
if ($randomnumber== "16") {
include ("ads/ad17.inc");
}
if ($randomnumber== "17") {
include ("ads/ad18.inc");
}
if ($randomnumber== "18") {
include ("ads/ad19.inc");
}
if ($randomnumber== "19") {
include ("ads/ad20.inc");
}
if ($randomnumber== "20") {
include ("ads/ad21.inc");
}
if ($randomnumber== "21") {
include ("ads/ad22.inc");
}
if ($randomnumber== "22") {
include ("ads/ad23.inc");
}
if ($randomnumber== "23") {
include ("ads/ad24.inc");
}
if ($randomnumber== "24") {
include ("ads/ad25.inc");
}
?>
Those are the only two scripts I could find. If you know of a better one then I would be grateful. yes the second is PHP so there goes the Javascript idea!
no1golfpro.co.uk - High quality golf equipment at competitive prices.
Renegade posted this at 04:00 — 21st April 2003.
He has: 3,022 posts
Joined: Oct 2002
There must be an easier way to code that PHP, maybe use an array or a loop for that. :S
Timewell posted this at 18:33 — 25th April 2003.
They have: 344 posts
Joined: Jun 2002
I dunno...it isn't my code, the random script thing. I just found it on Hotscripts.com
fspigroup posted this at 21:13 — 25th April 2003.
They have: 5 posts
Joined: Feb 2003
wouldnt it be easier to create a drop down list that has all 39 options..
then that will tell the 2 nd drop down the amount of options to display from the previous selection (fruit), the viewer then selects Oranges from the 2nd drop down which has a jump url attached to it and brings the viewer to a new page wth a random list of available oranges?
If this sounds like something you can live with drop me a line.
DB
http://www.fspigroup.com
http://www.fsprom.com
http://www.fsprecords.com
http://www.fspsiteweaver.co.uk
Timewell posted this at 13:40 — 27th April 2003.
They have: 344 posts
Joined: Jun 2002
No because it would be mixing things that are not mixable if you understand me..
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.