By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,677 Members | 1,060 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,677 IT Pros & Developers. It's quick & easy.

Change image button type problem in IE

P: n/a
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

Aug 7 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a

Ph******@bigpond.net.au wrote:
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.
--
Rob

Aug 7 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.