Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

How to hide the submit button

+3 votes
asked Aug 6, 2014 in Q2A Core by Nicol
How to:

When the user clicked the send, button "send"  to disappear.
commented Aug 6, 2014 by pupi1985
What send button? Can you provide a screenshot? What is the exact behaviour after pressing that button and why do you want that to happen?
commented Aug 7, 2014 by Registered user 26
Sometimes it puts the question twice. When 2x quick clicks on submit, is created the same question twice.
How to do this:
After clicking on the send button, that button disappeared and could not squeeze again.

1 Answer

+2 votes
answered Aug 7, 2014 by pupi1985
edited Aug 7, 2014 by pupi1985
This is a very good catch. I wonder how everyone have missed it until now. I'm not sure if I should call this a bug, though. But I'm pretty sure this is an issue.
In order to reproduce this, you can perform a double click on the button or even hit the ENTER key twice very fast when the cursor is in the tags field, for example.
The simple workaround would be (assuming Q2A v1.6.3):
1. Locate file qa-include/qa-page-ask.php
2. Look for this line:
$qa_content=qa_content_prepare(false, array_keys(qa_category_path($categories, @$in['categoryid'])));
3. Add the following lines after the line found in the previous step:
$qa_content['script_var']['qa_form_submitted'] = 0;  // Unable to use boolean values due to qa_js function
$qa_content['body_footer'] = '
               $("form[name=' . qa_js('ask') . ']").submit(function(event) {
                    if (qa_form_submitted == 1)
                         qa_form_submitted = 1;
4. Test it in Chrome, FireFox, Internet Explorer and Safari (if possible)
5. Report back with the results of the test (if it is working or not for each browser)
Note the change doesn't hide the button but rather it just disables the form submission, which I guess it is better as it will also handle submission by hitting the ENTER key twice.
commented Aug 8, 2014 by Registered user 26
I only have Google Chrome and it works 100%. Thank you
commented Aug 8, 2014 by pupi1985
Good to know. I guess you should select the answer then in order to keep the Unanswered questions list as small as possible.
commented Aug 17, 2014 by yerbol89kz
@pupi1985 please add its code core in 1.7 beta version.