Text link instead of Submit button in Forms

Discussion in 'Programming' started by Romek, Feb 24, 2009.

  1. #1
    How to use text link in forms instead of Submit button?
     
    Romek, Feb 24, 2009 IP
  2. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
  3. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #3
    <form name="some_name" ........>

    Then on link use

    <a href="javascript:some_name.submit()"> Submit Form </a>

    I hope it helps.

    regards
     
    Vooler, Feb 25, 2009 IP
  4. Romek

    Romek Member

    Messages:
    83
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    45
    #4
    Not works. :( My code is:

     
    Romek, Feb 26, 2009 IP
  5. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #5
    This might be problem
    The id and name property are both "form" try another name and let ne know.

    Besides there is absolutely no need to have id proeprty of form because at document level name works just fine in all browsers.

    try this:

    <form method=\"post\" name=\"abc\">

    then

    <a href=\"javascript:abc.submit()\">wyślij</a>

    or

    <a href=\"javascript:document.forms[0].submit()\">wyślij</a> # am not 100% sure about this since never used forms property of document
     
    Vooler, Mar 1, 2009 IP
  6. buldozerceto

    buldozerceto Active Member

    Messages:
    1,137
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    88
    #6
    You can use document.abc.submit() in the example above also.
     
    buldozerceto, Mar 2, 2009 IP
  7. Steve_D

    Steve_D Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    another way would be to do a transparent image with the text on and then use this as the button image.
     
    Steve_D, Mar 2, 2009 IP
  8. Romek

    Romek Member

    Messages:
    83
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    45
    #8
    I trayed all examples, but not works in my script. :(
     
    Romek, Mar 3, 2009 IP
  9. alexpr07

    alexpr07 Active Member

    Messages:
    284
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    73
    #9
    Rename the form id and name.
    Instead of: <form method=\"post\" id=\"form\" name=\"form\">
    Write: <form method=\"post\" id=\"myform\" name=\"myform\">

    and

    Instead of: <a href=\"javascript:form.submit()\">wyślij</a>
    Write: <a href=\"javascript:document.myform.submit()\">wyślij</a>

    I'm not so familiar with PHP, but can you use single quotes instead?
    Like: <a href='javascript:document.myform.submit()'>wyślij</a>
     
    alexpr07, Mar 4, 2009 IP
  10. Joak1m

    Joak1m Peon

    Messages:
    135
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #10
    It doesn't work because of this:
    if (empty($_POST['submit'])) {
    PHP:
    You are checking, if it was submitted by a button named "submit".
     
    Joak1m, Mar 5, 2009 IP
  11. Romek

    Romek Member

    Messages:
    83
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    45
    #11
    So should I delete it?
     
    Romek, Mar 8, 2009 IP
  12. Romek

    Romek Member

    Messages:
    83
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    45
    #12
    When I deleteing this line - it's not work. How can I repair this script?
     
    Romek, Mar 15, 2009 IP
  13. Joak1m

    Joak1m Peon

    Messages:
    135
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #13
    
    <a href="javascript: document.form.submit();" id="submit">Search</a>
    
    HTML:
     
    Joak1m, Mar 16, 2009 IP
  14. Romek

    Romek Member

    Messages:
    83
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    45
    #14
    Not works too. :(
     
    Romek, Mar 16, 2009 IP