Jump to content

Reading data from drop-down lists and forms


Recommended Posts

I am developing a website for football league statistics and I wish to create drop-down menues for every club containing players names (for example: Player1....Players20). For every selected player I want to input the number of played minutes per game. I want to input this in a prompt box next to each player name.After that, I need to read these data and sum this to the previous games to have statistics about total played minutes per game for every player.The main problem is then is how to read data from a form and how to connect that to a given player name.Best regards

Link to comment
Share on other sites

accessing form elements can be done either by accessing by id where you would (to access the object) type


or by name which is the most cross-browser compatible, such as


using a reference for the various form element object values will help too. to get a name from a dropdown such as follows:

<form name="test_form">	<select name="sel1" id="sel2">		<option value="1">Player One</option>		<option value="2">Player Two</option>		<option value="3">Player Three</option>		<option value="4">Player Four</option>		<option value="5">Player Five</option>	</select></form></form>

would require you to access it as follows for best browser compatibility:


unless of course the script is in an event for the object, where you can use the


notation. hope this helps :)

Link to comment
Share on other sites

Many thanks Pierre, but I am still confused. I have some experience with html and started learning Javascript few weeks ago.I have a drop-down list with the player names and a form box to put in the number of played minutes (integer values). I can have also other check boxes for yellow/red cards.Once this is filled out, I want to access the data to do statistics later. I want to pick the played minutes for every players from the respective form, a 1 or 0 for taking a yellow/red card or not, and so on.Adavnce thank. :)

Link to comment
Share on other sites

well this is where one usually has to start thinking bigger, to using databases and a backend language like php or asp. javascript is only for the client side. if you want to go about it this way, you could store the time played in the individual option values, ticking it on either every 60 seconds or every second per individual player. the problem with using something like javascript for this whole thing though, is that you wouldnt be able to store it unless in a cookie. and then the values are only for that specific browser that was visiting the page.

Edited by Pierre 'Greywacke' du Toit
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...