Go Back   Novahq.net Forum > Computers > Web design and Programming

Web design and Programming Discuss website creation and other programming topics.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-05-2010, 09:54 AM
katana*GFR* is offline katana*GFR*

Join Date: May 2002
Location: North Sea
Posts: 2,421

Send a message via ICQ to katana*GFR* Send a message via MSN to katana*GFR*
Dropdown bozes and calculating?

Heya,

i need a kickass direction to something i want to create ^^

I need 3 dropdown menu's next to eachother in which people can select an item and its bonus names..

Small explanation, in that game ( gladiatus ) we have items with an prefix and suffix, they are used to give a basic items its extra stats.

What i want to do is to make it available online ( only working "script" i got is excel )


How should it look? :

3 dropdowns:


|Prefix| ---- |Item| ---- |Suffix|

List of stats
-stat 1
-stat 2
-stat 3
-stat 4
-stat 5
-stat 6


When clicking on it you will be presented with a list of names and when you make your selection it will calculate the stats and show them to you underneath it.

I got no idea on how to start off, so i need some general directions, or even better an example

Since the different prefixes and suffixes make up different statistics it needs to calculate the items to given formula..


I hope i made it a bit clear on what i ment ^^

Site im planning to put it on is just a html / css site, nothing fancy there.





*edit, yes i messed up the title, ment Boxes ^^
__________________
<- Sponsored by Chris



Found on Youtube:
Quote:
And if Newton Faulkner's voice can be described as "R&B" then Kurt Cobain must be a member of Boyz II Men.
Link here

Last edited by katana*GFR*; 12-05-2010 at 11:47 AM.
Reply With Quote
  #2  
Old 12-05-2010, 11:06 AM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,919

Whats the formula? Some real live examples of the data and the end result would help alot. I'm sure this can be done with JavaScript..
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #3  
Old 12-05-2010, 11:43 AM
katana*GFR* is offline katana*GFR*

Join Date: May 2002
Location: North Sea
Posts: 2,421

Send a message via ICQ to katana*GFR* Send a message via MSN to katana*GFR*
I got an excel sheet which has the stuff in it, bu tmost formulas i got are in german ( which is most likely not your strongest foreign language ^^ )


i'll try to extract the formula again ^^ Been a while since we inserted it
Attached Files
File Type: zip Itemcalc-v0.7.zip (33.0 KB, 6 views)
__________________
<- Sponsored by Chris



Found on Youtube:
Quote:
And if Newton Faulkner's voice can be described as "R&B" then Kurt Cobain must be a member of Boyz II Men.
Link here
Reply With Quote
  #4  
Old 12-05-2010, 11:49 AM
katana*GFR* is offline katana*GFR*

Join Date: May 2002
Location: North Sea
Posts: 2,421

Send a message via ICQ to katana*GFR* Send a message via MSN to katana*GFR*
*(&%$^#$_(*$() Copy paste fails, it removes almost all txt.

so a image:
__________________
<- Sponsored by Chris



Found on Youtube:
Quote:
And if Newton Faulkner's voice can be described as "R&B" then Kurt Cobain must be a member of Boyz II Men.
Link here
Reply With Quote
  #5  
Old 12-05-2010, 06:45 PM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,919

It would take me a long time to decipher that info
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #6  
Old 12-06-2010, 02:06 AM
katana*GFR* is offline katana*GFR*

Join Date: May 2002
Location: North Sea
Posts: 2,421

Send a message via ICQ to katana*GFR* Send a message via MSN to katana*GFR*
Could you point me to some javascript info with these sorts of info Scott?
As im pretty beat up on what to look for exactly, google isn't as good as it used to be in the old days.. And looking through a miliion pages and trying to weed out the advert links sucks
__________________
<- Sponsored by Chris



Found on Youtube:
Quote:
And if Newton Faulkner's voice can be described as "R&B" then Kurt Cobain must be a member of Boyz II Men.
Link here
Reply With Quote
  #7  
Old 12-06-2010, 08:22 AM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,919

Yeah searching for quality info now days usually ends up in blog spam.

It looks like drop down's with multi dimensional arrays would work. After the data is gathered from each drop box, the formula needs to be applied to all the drop down's values.
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #8  
Old 12-06-2010, 09:16 AM
atholon is offline atholon
"ath-hole"

Join Date: Jan 2003
Location: Failville.
Posts: 11,357

Send a message via MSN to atholon
I think I know what you're talking about. Simple javascript should do the trick. I'll try and write something basic you can use.
__________________
Reply With Quote
  #9  
Old 12-06-2010, 09:39 AM
atholon is offline atholon
"ath-hole"

Join Date: Jan 2003
Location: Failville.
Posts: 11,357

Send a message via MSN to atholon
You could do something like this in javascript:

Code:
function DropDown(targetName)
{
	var dropDownInst = this;
	this.target = document.getElementById(targetName);	
	
	if(targetname == null || this.target == null)
		return;
	// better to add some sort of exception handling here
	
	// Create prefix array
	this.prefixes = ["prefix1", "prefix2", "prefix3"];	
	
	// Create DOM select object
	var prefixSelect = document.createElement("select");	
	this.addOptions(prefixSelect, prefixes);
	
	// This is where we handle adding the item
	prefixSelect.onchange = function(e){ dropDownInst.addItem(this); };
}
DropDown.prototype.addOptions = function(iSelect, iArray)
{
	for(var i=0; i<iArray.length; i++)
	{
		var option = document.createElement("option");
		option.value = iArray[i];
		option.text = iArray[i];
		iSelect.options.add(option);
	}	
}
DropDown.prototype.addItem(iSelect)
{
	var selectedValue = iSelect.options[iSelect.selectedIndex];
	
	switch(selectedValue)
	{
		case "desiredPrefix1":
			// Add code here to create a new select and append it to the target
			break;
		case "desiredPrefix2":
			// Add code here to create a new select and append it to the target
			break;
		case "desiredPrefix3":
			// Add code here to create a new select and append it to the target
			break;
		default:
			alert("An invalid selection occurred!");
	}
}
__________________
Reply With Quote
  #10  
Old 12-06-2010, 11:48 AM
katana*GFR* is offline katana*GFR*

Join Date: May 2002
Location: North Sea
Posts: 2,421

Send a message via ICQ to katana*GFR* Send a message via MSN to katana*GFR*
bah, sounds like time to start a java course.. ^^
To bad i knew it wasn't going to be easy ^^

Cheers for the code so far Atholon.
1 thing, this piece only uses the given item + a prefix right?


An would it be possible to read the Prefixes, Items and Suffixes from an .txt file or ini?
Since that is the easy part to create, then the script stay's clean withotu cluttering it with all data..

If i count all prefixes, items and suffixes im nearing ( rough estimate ) 350 lines.. ( each item on 1 line with its + and - effects.. ^^
__________________
<- Sponsored by Chris



Found on Youtube:
Quote:
And if Newton Faulkner's voice can be described as "R&B" then Kurt Cobain must be a member of Boyz II Men.
Link here
Reply With Quote
  #11  
Old 12-06-2010, 04:06 PM
atholon is offline atholon
"ath-hole"

Join Date: Jan 2003
Location: Failville.
Posts: 11,357

Send a message via MSN to atholon
Yeah the code I attached is not for the full thing, just an example. It basically is set to add a second dropdown box based on the selected values from the first dropdown.

If you want to load it from a text file you'd need a server-side language like PHP or ASP.net and use ajax calls. Javascript can't directly interface with files.

You could use a java applet, silverlight or flash to do the drop downs and read from a text file as well. Think it's easier with JS though.
__________________
Reply With Quote
  #12  
Old 12-06-2010, 04:16 PM
atholon is offline atholon
"ath-hole"

Join Date: Jan 2003
Location: Failville.
Posts: 11,357

Send a message via MSN to atholon
It might be easier to use ajax actually, because you could load the first drop-down with the default values. Then you'd make an ajax call to your code behind language, it would then filter the results for you, then you can pass it back through an ajax response as an array. You create another drop down and load it with the results stored in the array. Then you do the same thing for a third box.

It just gets sort of messy when you are dealing with several cascading dropdowns, you might be able to find something easier by using that search term "cascading dropdowns".

What programming languages do you use Katana? jQuery (a javascript library) makes it really easy to do ajax stuff.
__________________
Reply With Quote
  #13  
Old 12-06-2010, 04:39 PM
katana*GFR* is offline katana*GFR*

Join Date: May 2002
Location: North Sea
Posts: 2,421

Send a message via ICQ to katana*GFR* Send a message via MSN to katana*GFR*
Well atm only html ^^ I have been working on so many things that i never could catch up with anything more.. In all those years ^^

Might aswell make sure my excel file is updated with all details first and then try to start teaching myself some tricks.
Been checking out some java builders, but thats a small step to high for me, so let alone that i start Ajax..

I did save all this info tho ^^.

Any help is appreciated, and im willing to learn ^^

I still got my trustworthy DreamWeaver on my PC and that helps me out alot.. Im very visually minded, for html i do know my way by now, but that has taken me some time ^^





PS, msn is jigler@gladiatus.nl
And i can be catched on IRC also alot.. irc.onlinegamesnet.net/6660 Channel: #jigler

Just shout and i'll react asap ^^ on irc i got an bnc, and never change my name to reflect offline / online, so drop a query if you want to know for sure ^^
__________________
<- Sponsored by Chris



Found on Youtube:
Quote:
And if Newton Faulkner's voice can be described as "R&B" then Kurt Cobain must be a member of Boyz II Men.
Link here
Reply With Quote
  #14  
Old 12-06-2010, 05:41 PM
atholon is offline atholon
"ath-hole"

Join Date: Jan 2003
Location: Failville.
Posts: 11,357

Send a message via MSN to atholon
I guess I should have asked this question: Does your web host support PHP or Asp.net or is it something else? I've done Ajax stuff with both PHP and Asp.net and could probably write you something in a week or two. I am at the end of the semester in school so I've got finals next week and will have little time until they're over.

If you've got the stuff in excel that is great, you'd just have to save a .csv file and you could read the stuff in very easily.
__________________
Reply With Quote
  #15  
Old 12-07-2010, 05:33 AM
katana*GFR* is offline katana*GFR*

Join Date: May 2002
Location: North Sea
Posts: 2,421

Send a message via ICQ to katana*GFR* Send a message via MSN to katana*GFR*
it supports that offcourse :P

Another thing Atho, where should i focus on as next step after html? I do have to start learning this stuff myself.. But im a bit "lost in the woods" And google has gone downhill the last few years, like Scott mentioned ^^

Any help is always welcome, but i don't want to make it so that you gys do the work and i just sit back and watch.. That is something i hate ^^
__________________
<- Sponsored by Chris



Found on Youtube:
Quote:
And if Newton Faulkner's voice can be described as "R&B" then Kurt Cobain must be a member of Boyz II Men.
Link here
Reply With Quote
  #16  
Old 12-07-2010, 07:53 AM
atholon is offline atholon
"ath-hole"

Join Date: Jan 2003
Location: Failville.
Posts: 11,357

Send a message via MSN to atholon
I would focus on learning how to read a text file from PHP and using delimeters to break the text into usable data first.
__________________
Reply With Quote
  #17  
Old 12-07-2010, 11:43 AM
katana*GFR* is offline katana*GFR*

Join Date: May 2002
Location: North Sea
Posts: 2,421

Send a message via ICQ to katana*GFR* Send a message via MSN to katana*GFR*
o0 my post disappeared in the big mists of internet, or i just missed the submit button.. ^^

So i have dug myself a old copy of Lynda.com PHP Essential Training up..

Hello "Hello World" again ^^

Any further recommendations are welcome ^^
__________________
<- Sponsored by Chris



Found on Youtube:
Quote:
And if Newton Faulkner's voice can be described as "R&B" then Kurt Cobain must be a member of Boyz II Men.
Link here
Reply With Quote
  #18  
Old 12-07-2010, 05:54 PM
atholon is offline atholon
"ath-hole"

Join Date: Jan 2003
Location: Failville.
Posts: 11,357

Send a message via MSN to atholon
I'd look here for learning how to read a PHP file.

I'd look here for learning how to split the lines into the data arrays you want.

Once you've read those pages you should be able to open the file, read it line by line, break each line into an array with the implode method and have the data accessible from the codebehind.

Create an array of arrays as you read stuff in. Once you get to that point I'll help you with the javascript/ajax stuff

Pseudo code:
while there is a line
{
read line, use implode to break the line into an array
put array into another array
}

return the array
__________________

Last edited by atholon; 12-07-2010 at 06:06 PM.
Reply With Quote
  #19  
Old 12-08-2010, 06:48 PM
atholon is offline atholon
"ath-hole"

Join Date: Jan 2003
Location: Failville.
Posts: 11,357

Send a message via MSN to atholon
Bam, atholon fail, you'd use the function explode();

Here you go:
Code:
<?php

$file = fopen("yourfile.csv", "r") or exit("Unable to open file!");

// Row array
$rows = array();

while(!feof($file))
{
  $columnString = fgets($file);
  $columns = explode(",", $columnString);

  // Add the array of column items to the row
  $rows[] = $columns;  
}
// This would return ALL the data to the javascript with AJAX
echo(json_encode($rows));
?>
You could get away with making multiple AJAX requests and having the code behind filter it but I suggest just doing one AJAX request at the time the page loads. That way you don't have the annoying delay while the results are passed back.
__________________

Last edited by atholon; 12-08-2010 at 07:06 PM.
Reply With Quote
  #20  
Old 12-08-2010, 07:52 PM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,919

Katana.. Do you have the password to un-protect the cells? The biggest hurdle here is the language, and not being able to pry into the excel formula.

It's more complicated than just building an array. If you look at how cell E are calculated on the first tab, you will see that not everything prefix+item+suffix but there are also conditional statements...
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
calculating ping times [HELP ME!!] RuleXXL Delta Force 0 09-06-2008 02:36 PM
calculating pimg times? Mackem Delta Force 1 08-19-2006 10:14 AM
100% CSS Dropdown Menus Scott Web design and Programming 4 03-12-2005 12:37 AM


All times are GMT -5. The time now is 04:15 AM.




Powered by vBulletin®