URL Parameter Question

velcrow

New Member
I would like to craft a URL to the web site below with parameters (in the URL) that force the drop down menu on the site to have 'NCAA FOOTBALL' selected instead of what the site has as default. I want to do this WITHOUT modifying the site below -- just a crafted URL.

"http://www.easportsworld.com/en_US/stats/index/id/3508/index.html"

I want to select different sports in the Game: drop down box.

Code for that box on the EA site is here:
Code:
 <label for="game_data">Game:</label> <select name="game_data" id="game_data" onChange="SONET.stats.updater(&quot;/en_US&quot;,&quot;&quot;,&quot;&quot;,&quot;3508&quot;,&quot;&quot;);"><option value="UEFA 08" selected="selected">UEFA Euro 2008&trade;</option>

<option value="NASCAR">NASCAR</option>
<option value="NCAA">NCAA Football</option>
<option value="MADDEN">MADDEN</option>
<option value="HEADCOACH">HEAD COACH</option>
<option value="NHL">NHL</option>
<option value="NBA">NBA</option>
<option value="FIFA">FIFA 09</option>
<option value="TIGER">TIGER WOODS 09</option>
<option value="MMAD">NCAA BASKETBALL</option>

</select>&nbsp;

Could someone help me figure out how to do such a thing -- i've tried for hours and just can't figure it out?

THANKS
 
Last edited:

conor

New Member
You will need to pass a paramater through the url. This is possible in JavaScript and PHP.

With PHP you could do something like this:

Code:
"http://www.easportsworld.com/en_US/stats/index/id/3508/index.php?menu=nca-football"

Then pick it up in your PHP document with:

Code:
<?php
//check if the menu appears in the URL - if not use default
$default = (isset($_GET['menu'])) ? $_GET['menu'] : 'default';
?>

Then you could use the default value to figure out which menu item should look like what.

As I said it can be done in JavaScript - which would probably be a better idea but my knowledge of that language is limited. You could try something like this.

Code:
// function to get the value passed by URL
var qsParm = new Array();
	function qs() {
		var query = window.location.search.substring(1);
		var parms = query.split('&');
		for (var i=0; i<parms.length; i++) {
			var pos = parms[i].indexOf('=');
			if (pos > 0) {
				var key = parms[i].substring(0,pos);
				var val = parms[i].substring(pos+1);
				qsParm[key] = val;
			}
		}
	}

// first set value as null
qsParm['menu'] = null;

// call the function
qs();

//set the value
var menuid = (qsParm['menu']) ? qsParm['menu'] : 'default';

// get the element by the id provided in the URL
var active = document.getElementById(menuid);

// set the background color of the active menu link as white
active.style.backgroundColor='#fff';

Basically what the above does is gets what you have entered into the url

ex. "http://www.easportsworld.com/en_US/stats/index/id/3508/index.html?menu=nca-football"

and tells it to set the background color of the element with the id 'nca-football' to white. You will obviously have to change this code a small bit depending on what you want to do with it.

Hope that helps.
 

velcrow

New Member
Thank you for the reply.... I edited my main question for clarity -- also below...

I should re-phrase --- Is there a way to craft a URL to select an option from that menu -- WITHOUT changing the code on the site?

site: http://www.easportsworld.com/en_US/stats/index/id/3508/index.html

I want to select different sports in the Game: drop down box.

Code for that box on the EA site is here:
Code:
 <label for="game_data">Game:</label> <select name="game_data" id="game_data" onChange="SONET.stats.updater(&quot;/en_US&quot;,&quot;&quot;,&quot;&quot;,&quot;3508&quot;,&quot;&quot;);"><option value="UEFA 08" selected="selected">UEFA Euro 2008&trade;</option>

<option value="NASCAR">NASCAR</option>
<option value="NCAA">NCAA Football</option>
<option value="MADDEN">MADDEN</option>
<option value="HEADCOACH">HEAD COACH</option>
<option value="NHL">NHL</option>
<option value="NBA">NBA</option>
<option value="FIFA">FIFA 09</option>
<option value="TIGER">TIGER WOODS 09</option>
<option value="MMAD">NCAA BASKETBALL</option>

</select>&nbsp;
 
Last edited:

conor

New Member
If you don't change the code then you don't change what happens on the page - simple as that!

If you add something to the URL you need to add something to the code to interpret that URL or else it means nothing. I could show you something with minimal change to the code but you would still need to change some things!
 
Top