Check if javascript is disabled in the client machine or not.
Joydeep Sen
Dont forget to click “Mark as Answer” on the post that helped you.This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers
Is the javascript kept in a separate javascript file. If show make sure given proper relative path in <link href=~/Includes/Scripts.js runat='Server' Make sure lamda symbol and run at server in ref link
Thanks
Hari
---------------------------------------------
Dont forget to click "Mark as Answer" on the post that helped you.
Here the PayMode is a div tag, in which exist a set of server controls. which i want to make visible or hide based on user selection. I have tried both the syntax- document.getElementById('').setAttribute('value',' '); document.getElementById("').setAttribute('value','');
But now its throwing JavaScript error, saying that. document.getElementById(...) is null or not an object. pls help.
varun5318
Member
6 Points
18 Posts
javascript working on my machine (application server), but not on client.
Mar 24, 2009 12:24 PM|LINK
I am making a div container visible or hidden based on user selection using javascript and css.
like a javascript function is -
function funHide(){
document.getElementById(
'PayMode').setAttribute('class','CntrlHidden'); document.getElementById('ctl00_ContentPlaceHolder1_TxtDrawnOn').setAttribute('value',' ');}
and css is -
/*For making a control block hidden.*/
.CntrlHidden
{
visibility:hidden;display:none;}/*For making a control block visible.*/
.CntrlVisible
{
visibility:visible;display:block;}Javascript is working perfectly fine once i am accessing site on my machine(which is also development as well as testing server), using IIS.
but on client machines browser, it is not working.
please help.
joydeepsen
Contributor
4155 Points
802 Posts
Re: javascript working on my machine (application server), but not on client.
Mar 24, 2009 12:33 PM|LINK
hi Varun,
Check if javascript is disabled in the client machine or not.
Dont forget to click “Mark as Answer” on the post that helped you.This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers
hariram.p@li...
Contributor
3366 Points
707 Posts
Re: javascript working on my machine (application server), but not on client.
Mar 24, 2009 12:34 PM|LINK
Have you check is javascript enabled in the client browser
Hari
---------------------------------------------
Dont forget to click "Mark as Answer" on the post that helped you.
My Site
varun5318
Member
6 Points
18 Posts
Re: javascript working on my machine (application server), but not on client.
Mar 25, 2009 05:19 AM|LINK
Yes JavaScript is enabled in client browsers.
A similar code, is working in an older application; that we had developed using VS2005.
Now I am working with VS2008.
Though its should not be the case with VS2008.
But the thing making me disturb, that I am accessing the page using IIS, and then its working on my machine only.
hariram.p@li...
Contributor
3366 Points
707 Posts
Re: javascript working on my machine (application server), but not on client.
Mar 25, 2009 05:24 AM|LINK
Is the javascript kept in a separate javascript file. If show make sure given proper relative path in <link href=~/Includes/Scripts.js runat='Server' Make sure lamda symbol and run at server in ref link
Hari
---------------------------------------------
Dont forget to click "Mark as Answer" on the post that helped you.
My Site
paaresh
Contributor
2104 Points
311 Posts
Re: javascript working on my machine (application server), but not on client.
Mar 25, 2009 05:34 AM|LINK
Hi..
please also check that id you are using in document.getElementById, client browser generating same id in HTML. pls check in viewsource
or better using obj.ClientID in document.getElementById
ex: document.getElementById('<%=obj.ClientID%>');
[Ahmedabad]
|| Blog ||
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: javascript working on my machine (application server), but not on client.
Mar 25, 2009 05:49 AM|LINK
try this instead
function funHide(){
document.getElementById('PayMode').setAttribute('class','CntrlHidden'); document.getElementById("<%=TxtDrawnOn.ClientID%>").setAttribute('value',' ');}
Contact me
shashankgwl
All-Star
18926 Points
3662 Posts
Re: javascript working on my machine (application server), but not on client.
Mar 25, 2009 06:04 AM|LINK
function funHide()
{
document.getElementById('PayMode').setAttribute('class','CntrlHidden');
document.getElementById('ctl00_ContentPlaceHolder1_TxtDrawnOn').setAttribute('value',' ');}
what typeof control is PayMode, you need to get its correct ClientID from server?
replace the second line with this
document.getElementById('<%ContentPlaceHolder1.FindControl("TxtDrawnOn").ClientID %>').setAttribute('value',' ');
All is well if it runs well.
blog
varun5318
Member
6 Points
18 Posts
Re: javascript working on my machine (application server), but not on client.
Mar 25, 2009 08:51 AM|LINK
shashankgwl
All-Star
18926 Points
3662 Posts
Re: javascript working on my machine (application server), but not on client.
Mar 25, 2009 09:05 AM|LINK
1. Make sure that PayMode id is there when you do the view source of the page. because i doubt that is is
ctl00_ContentPlaceHolder1_PayMode
2. if a div with paymode id is there , then , replace
document.getElementById('PayMode').setAttribute('class','CntrlHidden');
with
document.getElementById('PayMode').className ="CntrlHidden" ;
3. where are you getting the error,
document.getElementById('PayMode').setAttribute('class','CntrlHidden');
or
document.getElementById('ctl00_ContentPlaceHolder1_TxtDrawnOn').setAttribute('value',' ');
debug this way,
function funHide()
{
try
document.getElementById('PayMode').setAttribute('class','CntrlHidden');
document.getElementById('ctl00_ContentPlaceHolder1_TxtDrawnOn').setAttribute('value',' ');
}
catch(e)
{
alert(e.message);
return false;
}
}
All is well if it runs well.
blog