esbesb
asked on
return a javascript variable to a ahref
Hi
In order to check whether a user has javascript enabled on each page LOAD - I need a way of feeding a javascript variable into a ahref (becasue the links avoid posting form variables and a session variable on javascript needs to be updated on every page)
Heres thef unction
function JSTrueOrFalse()
{
indicatejavascript();
var JStester;
if (document.frmSearch.textJa vascript.v alue == "JS is on")
{
JStester = "ON";
alert("it's on");
return JStester;
}
else
{
JStester = "OFF";
alert("it's off");
return JStester;
}
}
Can you feed into a ref like
<a href="ProcessMeetingReques ts.cfm?Jav ascript=" & return JSTester();>testing</a>
(doesn't work of course)
This is probably not possible - mixing server side and client side but has anyone invented a solution to this problem of testing javascript on page loads for links?
Thanks
In order to check whether a user has javascript enabled on each page LOAD - I need a way of feeding a javascript variable into a ahref (becasue the links avoid posting form variables and a session variable on javascript needs to be updated on every page)
Heres thef unction
function JSTrueOrFalse()
{
indicatejavascript();
var JStester;
if (document.frmSearch.textJa
{
JStester = "ON";
alert("it's on");
return JStester;
}
else
{
JStester = "OFF";
alert("it's off");
return JStester;
}
}
Can you feed into a ref like
<a href="ProcessMeetingReques
(doesn't work of course)
This is probably not possible - mixing server side and client side but has anyone invented a solution to this problem of testing javascript on page loads for links?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<script>
document.write('<a href="ProcessMeetingReques ts.cfm?Jav ascript=' + JSTrueOrFalse());
</script>
maybe...? or have it like...
<a href="ProcessMeetingReques ts.cfm?Jav ascript=OF F" onClick="window.location.h ref='Proce ssMeetingR equests.cf m?Javascri pt=ON'">te sting</a>
since event handlers won't work without JavaScript.
btw, how would you make this...
function JSTrueOrFalse()
{
indicatejavascript();
var JStester;
if (document.frmSearch.textJa vascript.v alue == "JS is on")
{
JStester = "ON";
alert("it's on");
return JStester;
}
else
{
JStester = "OFF";
alert("it's off");
return JStester;
}
}
function work if JavaScript is not enabled on the system?????? how'd the page see it has JS if it would use JS to check...??? using a function to return a value???
document.write('<a href="ProcessMeetingReques
</script>
maybe...? or have it like...
<a href="ProcessMeetingReques
since event handlers won't work without JavaScript.
btw, how would you make this...
function JSTrueOrFalse()
{
indicatejavascript();
var JStester;
if (document.frmSearch.textJa
{
JStester = "ON";
alert("it's on");
return JStester;
}
else
{
JStester = "OFF";
alert("it's off");
return JStester;
}
}
function work if JavaScript is not enabled on the system?????? how'd the page see it has JS if it would use JS to check...??? using a function to return a value???
@gam3r: And exactly where do you post the added information that I did not already post?
But good point anyway... which is why I use noscript
ASKER
Fantastic mplungjan - Had intended to test if Javascript remained Javascript=
but this is far far better and avoids hidden fields - many many thanks
but this is far far better and avoids hidden fields - many many thanks
YW :)
No need to test a hidden field.
If you insist on your field, try this
<a href="ProcessMeetingReques
onClick="this.href=this.hr
or
<script>
document.write('<a href="ProcessMeetingReques
</script>
<noscript>
<a href="ProcessMeetingReques
</noscript>