Click to See Complete Forum and Search --> : A + B = C
Alcarcalimo
02-14-2003, 02:39 PM
Ok, I'm working on a page which will hold lunarium codes for the AMIGA version of a game called Rocket Ranger (Like the movie "The Rocketeer".)
I want the people to use two dropdown menu's to choose the land they came from and the land they're going to and then give them the code instantly without having to submit it.
I got the dropdown menu's to work, with landcodes 000 to 026 for the "from" and 100 to 126 for the "to" menu.
Now all I want is the code for the box which gives them the correct amount of lunarium (2 digits).
Can anyone help me with that?
This is the code I have so far:
*Removed to shorten the thread*
If anyone could help me further, I would appreciate it.
Alcarcalimo
02-14-2003, 03:19 PM
No, I've got a whole list of 2 digit codes, all I need is for the site to find the correct location of the code.
You know, get the from+to codes and find the correct number.
Like this:
From Algeria
to Arabia
Code = 000 + 001 = 28
With the 28 located on the (000,001) coordinates.
khalidali63
02-14-2003, 03:41 PM
I guess this is what you want
<script type="text/javascript">
function process(){
var first = document.CountryForm.CountryFrom[document.CountryForm.CountryFrom.selectedIndex].value;
var second = document.CountryForm.CountryTo[document.CountryForm.CountryTo.selectedIndex].value;
// 2 values first and second you can do calculations at.
if(first!=="-111" && second!="-111"){//make sure both boxes are selected
alert(first+" , "+second);
}
//delete the alert line above when u do not need it
}
</script>
</head>
<body>
<form name="CountryForm">
<table bordercolorlight="#C0C0C0" border="2" bordercolordark="#000000" bordercolor="#808080">
<tr>
<td align=center><b>From:</b></td>
<td align=center><b>To:</b></td>
<td align=center><b>Amount of Lunarium:<b></td>
</tr>
<tr>
<td align=center>
<select name="CountryFrom" class="codes" onchange="process();">
<option value="-111">----</option>
<option value="000">Algeria</option>
<option value="001">Arabia</option>
<option value="002">Atlantic</option>
<option value="003">Brazil</option>
<option value="004">Canada</option>
<option value="005">Columbia</option>
<option value="006">Congo</option>
<option value="007">East Africa</option>
<option value="008">Egypt</option>
<option value="009">England</option>
<option value="010">France</option>
<option value="011">Germany</option>
<option value="012">Italy</option>
<option value="013">Kenya</option>
<option value="014">Libya</option>
<option value="015">Mideast</option>
<option value="016">Nigeria</option>
<option value="017">Persia</option>
<option value="018">Peru</option>
<option value="019">Scandinavia</option>
<option value="020">Spain</option>
<option value="021">Sudan</option>
<option value="022">U.S.A.</option>
<option value="023">U.S.S.R.</option>
<option value="024">Venezuela</option>
<option value="025">West Africa</option>
<option value="026">Yugoslavia</option>
</select>
</td>
<td align=center>
<select name="CountryTo" class="codes" onchange="process();">
<option value="-111">----</option>
<option value="100">Algeria</option>
<option value="101">Arabia</option>
<option value="102">Atlantic</option>
<option value="103">Brazil</option>
<option value="104">Canada</option>
<option value="105">Columbia</option>
<option value="106">Congo</option>
<option value="107">East Africa</option>
<option value="108">Egypt</option>
<option value="109">England</option>
<option value="110">France</option>
<option value="111">Germany</option>
<option value="112">Italy</option>
<option value="113">Kenya</option>
<option value="114">Libya</option>
<option value="115">Mideast</option>
<option value="116">Nigeria</option>
<option value="117">Persia</option>
<option value="118">Peru</option>
<option value="119">Scandinavia</option>
<option value="120">Spain</option>
<option value="121">Sudan</option>
<option value="122">U.S.A.</option>
<option value="123">U.S.S.R.</option>
<option value="124">Venezuela</option>
<option value="125">West Africa</option>
<option value="126">Yugoslavia</option>
</select>
</td>
<td align=center><INPUT TYPE="text" NAME="output" SIZE="2" onFocus="this.blur()"></td>
</tr>
</table>
</form>
Khalid
Alcarcalimo
02-14-2003, 03:45 PM
eehm.. well, yes... but...
I think we're not on the same line.. It maight be me (I'm certain it is...), but I mean to say, I've got 26x26 codes.
All of them need to be put in a list, from where they can be found with the "from"+"to" selectors.
When they are found in such a way, they need to be put in a read-only box of 2 digits wide.
It doesn't matter to me how big a code I have to use, as long as it works.
Got it? (English is not my native language, so I hope I said it right...)
khalidali63
02-14-2003, 03:54 PM
In that case you have to revisit the whole logic,or to be the least you have to have another array or two that can hold the calculattion values which are then retrieved upon selections from the 2 existing drop downs.
I'd say, at this point, create a file with all of the data which you wnat ot be worked on and explain how exactly you want it to be coded,may be some one can help.to let us all keep guessing will not do any good.
cheers
Khalid
Alcarcalimo
02-14-2003, 04:15 PM
....I'm afraid I'm a little overwhelmed with that code.
I tried to paste it on several places, but I don't know what to think of it and the best I get is that it shows an error message.
Ok, what I want is the following:
This is the thing I have at the moment:
___A__B__C__D__E
A_01_02_03_04_05
B_06_07_08_09_10
C_11_12_13_14_15
D_16_17_18_19_20
E_21_22_23_24_25
This is what I want:
From:_______To:_________Code:
(Selector1)__(Selector2)__(Read-only box which shows the correct code.)
When Selector1 is set to A and Selector2 to B, the box should read 06.
When the Selectors are set to C,E it should change to 23 without prompting.
I hope this helps...?
Alcarcalimo
02-14-2003, 04:49 PM
..eehm.. ok, but where do I put the array?
Alcarcalimo
02-14-2003, 05:03 PM
Well, it won't work! So either I've done something completely stupid, or the code ain't right.
I'll paste it here:
*Removed to shorten the thread*
Zach Elfers
02-14-2003, 05:08 PM
All your arrays with your 26 numbers are in between <script> and </script> tags. Change the first to <script language="JavaScript" type="text/JavaScript">
Alcarcalimo
02-14-2003, 05:10 PM
:eek: oops! Dôh! :p
...
But it still won't work! :mad:
Zach Elfers
02-14-2003, 05:15 PM
Try cutting all those arrays out and pasting them before the function in the top script.
Alcarcalimo
02-14-2003, 05:26 PM
like this?
*Removed to shorten the thread*
Alcarcalimo
02-14-2003, 06:29 PM
oh... :confused:
Is this ok?
*Removed to shorten the thread*
I'm really struggling with this.....
Alcarcalimo
02-14-2003, 06:57 PM
YAY! :D
Many thanks!
It actually works!
Now all I have to do is to change the 26x26 codes to the good ones.... :rolleyes:
But this helps A LOT! :D
Alcarcalimo
02-14-2003, 07:06 PM
Oh, yes! :rolleyes:
Ok, you got me there....
I'll just put a link to your site on that page, to let people know who helped me code this thing. ;)
(Plus, I wrote in your guestbook! :p )