There is a form with a post request. First I would like to make the button inactive, or click to display an error message.

<form action="out.php" method="post"> <p>Укажите вашу ссылку: <input type="text" name="longurl" value="ссылка" /></p> <p>Описание: <input type="text" name="comment" value="описание" /></p> <input type="submit" name="button" value="OK"> </form> 

And below I bring some records from the database (text - hyperlink)

 <?php echo $row['comment']?> <a href="<?php echo $row['url']?>"> Посетить </a> 

I need, so that for some number of clicks on hyperlinks, the button becomes available or the message about the availability of the button appears.

Tell me how to implement it?

    1 answer 1

    change

     <input type="submit" name="button" value="OK"> 

    on

     <button id="my_button" disabled onclick="clickOkButton();">OK</button> 

    add the name = "myForm" property to the form tag

    Anywhere below this button, insert

     <script type="text/javascript"> var counter = 10; function clickOkButton(){ counter--; if(counter>0) return; if(counter == 0){ document.getElementById('my_button').disabled = false; return; } document.getElementById('myForm').submit(); } </script> 

    PS wrote on the move, there may be syntax errors, but the idea should be clear.

    • a bit unclear. Can I somehow change the counter in the right place? - sbaikov