Click to See Complete Forum and Search --> : Why isnt this working?


mcuk
01-24-2003, 07:45 AM
function alterDrop()
{
var d = document;
refPage = d.referrer.substr(d.referrer.lastIndexOf('/')+1);
if (refPage = "page1.htm")
{
d.form.enquiries.requiredsubject.value(page1);
}
else if (refPage = "page2.htm")
{
d.form.enquiries.requiredsubject.value(page2);
}
}

This is my code inside my SCRIPT tags inside the head. I have also put the onLoad="alterDrop();" in my BODY tags.

My aim is to make the dropdown box in my form auto select an option when the page opens, dependent on the referring page.

But it doesnt seem to be working... help me? please ???

khalidali63
01-24-2003, 07:58 AM
referrer might work or might now work depending upon the data in the HTTP headers.This information is web server dependent.
Hence unless you are creating this page for to bu run on your own webserver which is configured to carry this info,it might not work at all.

Khalid

mcuk
01-24-2003, 08:01 AM
cheers Khalid,

but i've tested the referrer by getting it to print out on screen using document.write(document.referrer) and it does print out.

It reads the referrer fine, which is what i cant undestand. It just doesnt seem to be able to set the value of the dropdown to correspond.

khalidali63
01-24-2003, 08:12 AM
And hence my point.
"You can not count on it."

mcuk
01-24-2003, 08:16 AM
would i be able to alter the html code of the OPTION tag in the dropdown instead of this:


if (refPage = "dir_nav.htm")
{
d.enquiries.requiredsubject.value("directorate");
}


for example, could i do something like this instead:


if (refPage = "dir_nav.htm")
{
insert text "selected " into <OPTION> tag of value corresponding with referring page;
}


is this possible, or am i showing my noviceness at coding? ;)