Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

detecting 'undefined'

Status
Not open for further replies.

shmmeee

Programmer
Apr 17, 2001
104
GB
OK you guys were so helpful with my last post I thought I'd give you my next problem. My code is as follows:
Code:
function get_defn(term_string)
{
	defn_string = eval(term_string.replace(/ /g,"_").toUpperCase());
	defn_array = defn_string.split("=");
	return defn_array[0]
};
function write_link()
{
	linkspot.innerHTML = '<a href=&quot;' + defn_array[1] + '&quot;>More Information</a>'
}

Defn_string is set out like this: description=URL
So defn_array[1] holds the URL, however for some descriptions there is no URL so defn_string is just: description
and defn_array[1] = 'undefined'
can I detect the absence <sp?> of a URL and act accordingly e.g:
Code:
function write_link()
{
if(defn_array[1]!='undefined')
	linkspot.innerHTML = '<a href=&quot;' + defn_array[1] + '&quot;>More Information</a>'
else
        linkspot.innerHTML = 'No link available';
}


Iain X-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top