Change image button type problem in IE

P

Phil_Cam

Hello All
On a webpage I have a standard paypal image button for purchases. I am
trying to set it up so that it only shows up or is endabled when text
is entered into a textbox and a button is pressed. To do this I set the
type to hidden and changed the type of the button using javascipt to
image. This works perfectly in Modilla's Firefox but in IE it says
there is a scipt error.

Here is the javascipt

<script type="text/javascript">
function UpdateFields() {
if (UsernameForm.txtUserName.value == "") {
var msg = "Please enter a User Name";
alert(msg);
return;
}
document.form8130.btnSubmit.type = "image";
document.form8130.on0.value = UsernameForm.txtUserName.value;
} //disabled="true"
</script>

The paypal button is setup as follows
<form name ="form8130" target="paypal"
action="https://www.paypal.com/cgi-bin/webscr" method="post">
<div align="center"><b><font color="#FFFFFF" size="-1"
face="Arial,Helvetica,Geneva,Sans-serif,sans-serif">
<input name="btnSubmit" type="hidden"
src="../../../images/Paypal/sc-but-03.gif" alt="Pay for your locomotive
with PayPal - it's fast, free and secure!" width="106" height="24"
border="0">
</font></b></div>
</form>


If I remove the following line from the script then I do not get the
error in IE

document.form8130.btnSubmit.type = "image";

Can anyone see what I have done wrong here? Is there another way to
enable or disable an image button?

Thanks in Advance

Phil
 
R

RobG

Hello All
On a webpage I have a standard paypal image button for purchases. I am
trying to set it up so that it only shows up or is endabled when text
is entered into a textbox and a button is pressed. To do this I set the
type to hidden and changed the type of the button using javascipt to
image. This works perfectly in Modilla's Firefox but in IE it says
there is a scipt error.

I think the idea of hiding the button completely creates a usability
issue - people may well wonder what the form is for if there is no
submit button.[1]

But anyhow, you could leave the input as type image and then set its
visibility to hidden or visible as required.

You could also set the button as 'disabled' and provide a disabled
image in the HTML, then swap to the 'enabled' image and enable the
button when you've validated the text input's content.

The usual caveat applies - anyone with javascript disabled/not
available will not be able to enable the button or to submit the form
unless you use script to disable it in the first place. That infers
that your server must be able to deal with invalid input, hence the
value of hiding/showing or disabling/enabling the button is moot.


1. People expect a standard submit button, many find image buttons
confusing. I've seen even experience users stare at standard Windows
install dialogs because the 'inatall' button looks nothing like a
standard dialog button. Most of the submit button images I've seen try
to look very much like a standard submit button for this reason, which
leads one back to question why an image is being used instead of a
standard submit button. It will also make users nervous about clicking
on images if some are used to submit forms.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,157
Latest member
MercedesE4
Top