Coding with Firefox: Alternative for "onclick"?

Discussion in 'Web Design & Coding' started by madmatt, Mar 7, 2007.

  1. madmatt

    madmatt Bow Down to the King Political User

    Messages:
    13,312
    Location:
    New York
    I'll admit, I am the typical Microsoft guy who doesn't bother with Firefox. I received an email from a client today with a problem that their online job application is not coming through. I decided to install Firefox on a virtual OS and see if it had something to do with the way Firefox handles the code.

    I didn't find a problem with the initial application but with the next step in the process.

    I am using a text link with the "onclick" property.

    PHP:
    <a href="#" class="menulink" onClick="submit();">Click here to take the affirmative action online survey.</a>
    I know there is a problem because Firefox does not support "onclick". Weird.

    I got tired of researching it so decided to ask. Thank you.
     
  2. albybum

    albybum Penguin Rancher

    Messages:
    280
    Location:
    Elizabethton, TN
    no caps, try onclick rather than onClick

    Also, you may need to be specific about the form being submitted.

    Alternatively, you can embed javascript in the href attribute.

    Like,
    Code:
     
    <a href="javascript:document.getElementById('frmGoogleSearch').submit();">Google Search!</a>
    
     
    Last edited: Mar 8, 2007
    madmatt likes this.
  3. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    as albybum said its most likely to be the attribute case. if you want to try it in firefox with a javascript console then download firebug as well for firefox
     
    madmatt likes this.
  4. madmatt

    madmatt Bow Down to the King Political User

    Messages:
    13,312
    Location:
    New York
    I'm not making any progress.

    PHP:
    <form method="POST" name="aasurvey" action="index.php?show=careers&sub=aasurvey">

      <input type="hidden" name="position" value="<?php print $_POST['position']; ?>">
      <input type="hidden" name="date" value="<?php print date('m/d/Y'); ?>">
      <input type="hidden" name="howDid" value="<?php print $_POST['howDid']; ?>">
      <input type="hidden" name="firstName" value="<?php print $_POST['firstName']; ?>">
      <input type="hidden" name="middleName" value="<?php print $_POST['middleName']; ?>">
      <input type="hidden" name="lastName" value="<?php print $_POST['lastName']; ?>">
      <input type="hidden" name="address" value="<?php print $_POST['address']; ?>">
      <input type="hidden" name="address2" value="<?php print $_POST['address2']; ?>">
      <input type="hidden" name="city" value="<?php print $_POST['city']; ?>">
      <input type="hidden" name="state" value="<?php print $_POST['state']; ?>">
      <input type="hidden" name="zipCode" value="<?php print $_POST['zipCode']; ?>">
      <input type="hidden" name="country" value="<?php print $_POST['country']; ?>">
      <input type="hidden" name="phoneNumber1" value="<?php print $_POST['phoneNumber1']; ?>">
      <input type="hidden" name="phoneNumber2" value="<?php print $_POST['phoneNumber2']; ?>">
      <input type="hidden" name="ssn" value="<?php print $_POST['ssn']; ?>">
      <input type="hidden" name="emailAddress1" value="<?php print $_POST['emailAddress1']; ?>">
      <input type="hidden" name="emailAddress2" value="<?php print $_POST['emailAddress2']; ?>">

      In an effort to comply with requirements regarding government recordkeeping, reporting, and other legal obligations which may apply, we invite you to complete the <a href="javascript:void(0);" class="menulink" onClick="submit();">affirmative action online survey</a>.  Providing this information is <b>STICTLY VOLUNTARY</b>.  Failure to provide it will not subject you to any adverse personnel decision or action.<br>

      &nbsp;<br>

      <a href="javascript:document.getElementById('aasurvey').submit();" class="menulink">Click here to take the affirmative action online survey.</a>

    </form>
    See final a href.

    First, I changed "onClick" to "onclick". No difference.

    Next, I changed it to the statement that alby suggested. No difference.

    Next, I installed Firebug and it's not telling me there is anything wrong.

    Furthmore, the statement alby gave me works perfectly with IE6 and IE7.
     
    Last edited: Mar 8, 2007
  5. Khayman

    Khayman I'm sorry Hal... Political User Folding Team

    Messages:
    5,518
    Location:
    England
    you are using "getElementById" but have not set the id of the form.

    Add id="aasurvey" to your form tag
     
    Geffy and madmatt like this.
  6. madmatt

    madmatt Bow Down to the King Political User

    Messages:
    13,312
    Location:
    New York
    Oh gee now I feel dumb. Thanks everyone.
     
  7. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    lol
     
  8. albybum

    albybum Penguin Rancher

    Messages:
    280
    Location:
    Elizabethton, TN
    This also works.

    Code:
     
    <a href="#" class="menulink" onclick="document.aasurvey.submit();">Click here to take the affirmative action online survey.</a> 
     
    
     
  9. X-Istence

    X-Istence * Political User

    Messages:
    6,498
    Location:
    USA
    It won't properly on certain browsers. Since some browsers won't populate the document namespace with all the "id" attributes. Konqueror being a prime example, neither does Safari.