Hyperlink Submit Button

Discussion in 'JavaScript' started by Weirfire, Dec 17, 2008.

  1. #1
    I have a hyperlink submit button inside one of my forms. This button is for a simple message system.

    <a href="#" onclick='document.getElementById("mailboxaction").value="read";document.forms["checkboxes"].submit();'>Read</a>
    PHP:
    This piece of code works perfectly in Internet Explorer but it won't even post the form in Firefox.

    I have tried setting the last piece of code that submits the form to "this.form.submit();" but neither work in Firefox.

    If anyone wants to try this on your own system then you can use the form below;

    <form action='' method='POST' name='checkboxes' id='checkboxes'>
      <input type='hidden' name='test_field' value='test field' />
      <input type='hidden' name='mailboxaction' value='' />
    </form>
    PHP:
    and stick this

    var_dump($_POST);
    PHP:

    at the top of the page to see the result of the post.

    If anyone has any ideas or solutions as to why this doesn't work in Firefox I would be forever grateful.

    So the full page of code should look something like;


    
    var_dump($_POST);
    
    
    <form action='' method='POST' name='checkboxes' id='checkboxes'>
    
    <a href="#" onclick='document.getElementById("mailboxaction").value="read";document.forms["checkboxes"].submit();'>Read</a>
    
    
      <input type='hidden' name='test_field' value='test field' />
      <input type='hidden' name='mailboxaction' value='' />
    </form>
    
    Code (markup):
    Thanks for taking a look! :D
     
    Weirfire, Dec 17, 2008 IP
  2. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #2
    I'm still needing a solution to this problem if anyone has any ideas? :)
     
    Weirfire, Dec 18, 2008 IP
  3. lp1051

    lp1051 Well-Known Member

    Messages:
    163
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #3
    Hi Weirfire,

    it's because IE is full of bugs. It should not work on IE either. Firefox is more accurate, so it doesn't let you call getElementById('mailboxaction') on hidden form field, that doesn't have any id="mailboxaction", only name...
    Or you can use document.forms["checkboxes"].mailboxaction.value="read" - that works on name

    Have a nice day in Ireland
     
    lp1051, Dec 18, 2008 IP