Ron
Posts: 26
|
Posted: 09/17/2004, 12:03 PM |
|
I'm using the following getParam function to retrieve a URL parameter:
function getParam(string,parm) {
var startPos = string.indexOf(parm + "=");
if (startPos > -1) {
startPos = startPos + parm.length + 1;
var endPos = string.indexOf("&",startPos);
if (endPos == -1)
endPos = string.length;
return unescape(string.substring(startPos,endPos));
}
return '';
}
I'm using the getParam function to set a variable in another function as follows:
function MenuShow(secid)
{
var intTeam = getParam(document.URL,"TeamID");
curr = secid;
if (intTeam > 0)
{
if (secid == 1) {document.images['tab_Home'].src = 'images/tab_Home-On.gif'};
if (secid == 2) {document.images['tab_TeamSched'].src = 'images/tab_TeamSched-On.gif'};
if (secid == 3) {document.images['tab_TeamRoster'].src = 'images/tab_TeamRoster-On.gif'};
if (secid == 4) {document.images['tab_TeamOrg'].src = 'images/tab_TeamOrg-On.gif'};
if (secid == 5) {document.images['tab_TeamPhoto'].src = 'images/tab_TeamPhoto-On.gif'};
}
else
{
if (secid == 1) {document.images['tab_Home'].src = 'images/tab_Home-On.gif'};
if (secid == 2) {document.images['tab_About'].src = 'images/tab_About-On.gif'};
if (secid == 3) {document.images['tab_Register'].src = 'images/tab_Register-On.gif'};
if (secid == 4) {document.images['tab_Team'].src = 'images/tab_Team-On.gif'};
if (secid == 5) {document.images['tab_Link'].src = 'images/tab_Link-On.gif'};
}
}
</script>
My problem is when there is no TeamID in the URL I get an Object Expected error on the following line:
var intTeam = getParam(document.URL,"TeamID");
How can I convert getParam(document.URL,"TeamID") to 0 if it returns a empty set?
|
|
|
biaapc
|
Posted: 10/05/2004, 2:31 PM |
|
Instead of:
return '';
use
return 0;
|
|
|
|