Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Change image button type problem in IE

Reply
Thread Tools

Change image button type problem in IE

 
 
Phil_Cam@bigpond.net.au
Guest
Posts: n/a
 
      08-07-2006
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

 
Reply With Quote
 
 
 
 
RobG
Guest
Posts: n/a
 
      08-07-2006

http://www.velocityreviews.com/forums/(E-Mail Removed) 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
change button type from "submit" to "button" Tony WONG ASP .Net 2 04-22-2010 06:45 AM
Creating a Button that is type="button" and does not call __doPostBack Nathan Sokalski ASP .Net Web Controls 1 01-11-2010 03:57 PM
Creating a Button that is type="button" and does not call __doPostBack Nathan Sokalski ASP .Net 1 01-11-2010 03:57 PM
asp button always rendered as type="button" vs. type="submit" Sam ASP .Net Web Controls 1 11-25-2008 06:14 PM
A Paradise DNS address change? What change? There was no change. Tony Neville NZ Computing 7 09-22-2006 01:02 PM



Advertisments