Change image button type problem in IE

Discussion in 'Javascript' started by Phil_Cam@bigpond.net.au, Aug 7, 2006.

  1. Guest

    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, 2006
    #1
    1. Advertising

  2. RobG Guest

    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
     
    RobG, Aug 7, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jacek Francuz
    Replies:
    0
    Views:
    378
    Jacek Francuz
    Apr 14, 2005
  2. Israel Richner

    Change background image of asp:button

    Israel Richner, Jan 8, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    7,596
    Israel Richner
    Jan 8, 2007
  3. Tony WONG
    Replies:
    2
    Views:
    603
    Tony WONG
    Apr 22, 2010
  4. Sam
    Replies:
    1
    Views:
    1,157
    Brian Kenneth Nielsen
    Nov 25, 2008
  5. Replies:
    2
    Views:
    111
Loading...

Share This Page