Click to See Complete Forum and Search --> : Ns4.08/4.77/4.79
mraghu
06-16-2003, 08:59 AM
The following code works fine in IE5.0,IE6.0 and NS6.2.3. But, it doesn't work in NS4.08/4.77/4.79. Could you please help? Thanks.
<form name="CHActivation" method="post">
<script language="javascript">
function DisableNext()
{
document.CHActivation.action="<cfoutput>#VisaApp.FullURL##XFA.EnrollThanks#&RequestTimeOut=500</cfoutput>";
document.CHActivation.submit();
document.getElementById('NextBtn').disabled = true;
document.getElementById('NextBtn').src="<cfoutput>#VisaApp.Images#</cfoutput>btn_next_off.gif";
document.getElementById('BackBtn').disabled = true;
document.getElementById('BackBtn').src="<cfoutput>#VisaApp.Images#</cfoutput>btn_back_off.gif";
}
function DisableBack()
{
document.CHActivation.action="<cfoutput>#VisaApp.FullURL##XFA.TsAndCsAccept#</cfoutput>";
document.CHActivation.submit();
document.getElementById('NextBtn').disabled = true;
document.getElementById('NextBtn').src="<cfoutput>#VisaApp.Images#</cfoutput>btn_next_off.gif";
document.getElementById('BackBtn').disabled = true;
document.getElementById('BackBtn').src="<cfoutput>#VisaApp.Images#</cfoutput>btn_back_off.gif";
}
</script>
<input type="image" name="NextBtn" src="<cfoutput>#VisaApp.Images#</cfoutput>btn_next.gif" id="NextBtn" alt="Next button" title="Next button" height="17" width="40" border="0" onclick="DisableNext()">
<p><input name="BackBtn" type="image" src="<cfoutput>#VisaApp.Images#</cfoutput>btn_back.gif" id="BackBtn" alt="Back button" title="Back button" height="17" width="40" border="0" onclick="DisableBack()"></p>
</form>
Khalid Ali
06-16-2003, 12:49 PM
Can you be more specific that what you expect your code to be doing which its not doing and the errors you get...for NS<5
mraghu
06-16-2003, 12:58 PM
When the user clicks on the "Next" or "Back" Image, I want to disable the Next(btn_next.gif) and Back(btn_back.gif) Images and show the greyed out Next(btn_next_off.gif) and Back(btn_back_off.gif) images so as to prevent multiple clicks.
This is working fine in IE5.0,6.0 and NS6.2.3. It neither disables nor shows the greyed out gifs in NS4 browsers. Could you please help? Thanks.
It doesn't work because getElementById does not work in NN 4.x
mraghu
06-16-2003, 01:14 PM
Thanks for getting back. What alternate code can I use to make the same functionality work in all browser versions?
It looks like they are form fields, so you can reference them like this:
document.formname.fieldname
mraghu
06-16-2003, 01:44 PM
Based on your hint, I tried using the following code.
I am getting "document.CHActivation.NextBtn" is null or not an object" How do I fix that?
<form name="CHActivation" method="post">
<script language="javascript">
function DisableNext()
{
document.CHActivation.action="<cfoutput>#VisaApp.FullURL##XFA.EnrollThanks#&RequestTimeOut=500</cfoutput>";
document.CHActivation.submit();
document.CHActivation.NextBtn.disabled=true;
document.CHActivation.NextBtn.src="<cfoutput>#VisaApp.Images#</cfoutput>btn_next_off.gif";
document.CHActivation.BackBtn.disabled=true;
document.CHActivation.BackBtn.src="<cfoutput>#VisaApp.Images#</cfoutput>btn_back_off.gif";
}
function DisableBack()
{
document.CHActivation.action="<cfoutput>#VisaApp.FullURL##XFA.TsAndCsAccept#</cfoutput>";
document.CHActivation.submit();
document.CHActivation.NextBtn.disabled=true;
document.CHActivation.NextBtn.src="<cfoutput>#VisaApp.Images#</cfoutput>btn_next_off.gif";
document.CHActivation.BackBtn.disabled=true;
document.CHActivation.BackBtn.src="<cfoutput>#VisaApp.Images#</cfoutput>btn_back_off.gif";
}
</script>
<input type="image" name="NextBtn" src="<cfoutput>#VisaApp.Images#</cfoutput>btn_next.gif" id="NextBtn" alt="Next button" title="Next button" height="17" width="40" border="0" onclick="DisableNext()">
<p><input name="BackBtn" type="image" src="<cfoutput>#VisaApp.Images#</cfoutput>btn_back.gif" id="BackBtn" alt="Back button" title="Back button" height="17" width="40" border="0" onclick="DisableBack()"></p>
</form>
Khalid Ali
06-17-2003, 08:26 AM
Honestly..I don't understand why and what is it exactly you are trying to do.Unlss you have a link where I can see what you said is working code for IE and NS6+.
anyways...by looking at your code the correct syntax for doing he exact samething in NS<5 is following
if(document.layers){
document.CHActivation.BackBtn.disabled = false;
document.CHActivation.NextBtn.disabled = true;
}else{
document.getElementById('NextBtn').disabled = true;
document.getElementById('NextBtn').src="images/button2b.gif";
document.getElementById('BackBtn').disabled = false;
document.getElementById('BackBtn').src="images/button1b.gif";
}
mraghu
06-17-2003, 08:57 AM
Thanks for getting back. I will try your solution and see how it works in NS<5 versions. Thanks.
mraghu
06-17-2003, 11:33 AM
Nope. Usage of layers didn't disable the Next and Prev Images in NS<5.
gil davis
06-17-2003, 01:28 PM
NS 4.x does not support "disabled" for form elements. However, the way your code is written, it will create one for you, then you have to explicitly test it. For example:
function DisableNext() {
if (!document.CHActivation.NextBtn.disabled)
{ // do the function }
if (!document.CHActivation.BackBtn.disabled)
{ // do the function }
}
Notice that it doesn't matter whether the "disabled" part has been created or not because if it does not exist, the compare is false.
mraghu
06-17-2003, 03:09 PM
The purpose of my function itself is to diable the "btn_next.gif" & "btn_back.gif" images as soon as the user clicks on any one of them and to show the greyed out "btn_next_off.gif" & "btn_back_off.gif "instead. How do you transform the code below as per your logic?
function DisableNext()
{
document.CHActivation.action="<cfoutput>#VisaApp.FullURL##XFA.EnrollThanks#&RequestTimeOut=500</cfoutput>";
document.CHActivation.submit();
document.getElementById('NextBtn').disabled = true;
document.getElementById('NextBtn').src="<cfoutput>#VisaApp.Images#</cfoutput>btn_next_off.gif";
document.getElementById('BackBtn').disabled = true;
document.getElementById('BackBtn').src="<cfoutput>#VisaApp.Images#</cfoutput>btn_back_off.gif";
}
gil davis
06-17-2003, 09:55 PM
You must not have read khalid's post about getElementById() - that NS 4.x does not support it.
function DisableNext() {
if (!document.CHActiveation.NextBtn.disabled)
{document.CHActivation.action="<cfoutput>#VisaApp.FullURL##XFA.EnrollThanks#&RequestTimeOut=500</cfoutput>";
document.CHActivation.submit();
document.CHActivation.NextBtn.disabled = true;
document.CHActivation.NextBtn.src="<cfoutput>#VisaApp.Images#</cfoutput>btn_next_off.gif";
document.CHActivation.BackBtn.disabled = true;
document.CHActivation.BackBtn.src="<cfoutput>#VisaApp.Images#</cfoutput>btn_back_off.gif";
}
}BTW, NS 4.x does not support onClick for an input type="image", anyway. See http://devedge.netscape.com/library/manuals/1998/htmlguide/tags10.html#1312530 . In fact, the image button does not appear in the form's elements array. So, even my example will not work in NS 4.x. You'll have to change the <input type="image"> to a simple image link with an onclick that submits the form for you, if you want it to work in NS 4.x.