Why do html form inputs automatically get disabled? - html

I am using the RightJS javascript framework. I'm not sure if that has anything to do with this behavior or not. I have a form on my page and I use $('some_form').send(); to send the form to the server via a Post. The form submission works fine and request goes through to the server without error but after all the inputs in the form become disabled. Does anyone know what might be causing this to happen?

You need to run the preventDefault() function
$('form').send({
spinner: $('spinner'),
onComplete: preventDefault()
});
Its a jQuery feature

Related

How to automatically enable a button

I have a button in a JSP which gets disabled after the first click. This is just to prevent multiple form submission at the same time. I want to enable the button once the form is submitted. My current logic keeps the button enabled and it seems like it bypass the disable property.
Without this.disabled = false button works perfectly fine by keeping the button disabled but I also want it to be enabled once the process is finished.
<input type="submit" class="esignReports" value="Export E-Sign Information" title="This function will provide you a 30 day download of all your eSign transactions." onclick="this.disabled=true;this.value='Please wait...';document.getElementById('viewIntegrationReport').submit();this.disabled = false">
Is there anyway to do it without JS
Thanks,
I think your button actually gets disabled but it gets re-enabled automatically because the submit is async, so you don't have enough time to see it's 'disabled' state. You could put console.log(this.state) before and after the submit() call to be sure.
There's no way to get a callback on submit() calls using plain Javascript (since it is supposed to send the info and reload the page). You'll need to use jQuery if you want to re-enable the button, using callbacks.

Unexpected form submit

I faced with a strange problem. I write ASP.NET web application.
I have form tag on the aspx page and submit in the form. When I click on the submit form's data are posted. It is ok. But if I close the page right after submit and then re-open it with Main Menu -> Recent Tabs (I use Google Chrome) the form's submit fires once again and data are posted too. I would like to avoid this behavior because repeated posting data to server is unwelcome and unexpected. It happens after select Recent Tabs only (when I prress Ctrl+Shift+T it does not happen) How could I prevent it? Thanks in advance
Check if it's a PostBack. If it is a PostBack then return.

Multiple times clicking form data saves that many records in chrome

I have a form built in Joomla 2.5 and ChronoForms, the form validation been done using MooTools. However in Chrome browser when I click multiple times the submit button, that many number of records get saved. This is not the issue in Mozilla or IE.
Is it a Chrome specific issue??
How can i disable the submit button on success of the validation??
Any feedback or solution is appreciated.
Regards,
happy coding
I figured this by adding a JavaScript code, which disabled the submit button after it was clicked and there were no validation error.
I had to modify some of the files from chronoform library to do this because when i added a normal JavaScript code, it used to disable the button after the submit button click, it did not check if the validation was fired or not, So, if the validation was fired i was not able to correct the validation error because it disabled my submit button.
Maybe check this "Prevent Double Submit" thread on the ChronoEngine forums:
http://chronoengine.com/forums/viewtopic.php?f=2&t=22439

php or other script to close browser session after html form submission

I recently implemented a .htpasswd based login page and am trying to figure out a certain way I have in mind to close the browser window (because that is how I can reset the authentication so the user cannot log in again).
My idea is that once the user logs in and submits the information on the form they have to fill out, the submission of the form would trigger a script to close the browser window in 5 seconds. The user would be warned before hand that this will happen.
I'm not a pro coder when it comes to scripting, any ideas? I haven't found much information on this specific topic.
With jquery/javascript you can use window.close()
An example using a button...
html
<button id="close">Close</button>
jquery
$(document).ready(function() {
$('#close').click(function(){
window.close();
});
});
For further info...

Execute a CGI each time a button was clicked without changing the current html page

I am starting my internship on a Home Server able to control mutliple domotics equipments from a web page. The global idea is that based on a click on a button, a certain script is spawned on the server and controls a microcontroller.
My tutor built a simple website he gave me, using AJAX to always stay on 1 page, and brings the menus according to user actions (they are hidden if not used, brought back to front if used).
I have set up an apache server which I configured to execute CGI scripts, and it works.
To always stay on one page, I used the '204 No Content' return trick, so that the server's answer to the page is 'I don't have anything to say, just stay on this page'.
But the one problem I have is that the CGI is launched only once. If I click the button for the first time it works, afterwards nothing happens.
I tried using the SSI (shtml) to use the in a button code instead of using a FORM with GET method but the script still won't execute twice.
I might be using the wrong tools. Should I keep going with CGIs ? Or is there something else (like AJAX, jquery) that actually is designed to do what I want ?
Thanks for having read.
EDIT : I have found a way around it (it's always when I'm desperate after looking for days for an answer that I go to forums and then find myself a nice solution in the next hour .... )
I used a basic link, and for some reason it has a different behaviour than using a button. Whatever. My interrogations on the technologies used still stand though :)
EDIT2 : My solution is crappy, for some reason the script is also called at page refresh (or when the page loads for the first time). It's strange, because since it's in the it should only be spawned when I click on it ...
Familiarize yourself with jQuery and its AJAX API. You can't make it not load a new page unless you use AJAX. Here is an example of what an AJAX call looks like:
$.ajax({
url: 'http://server.domain.com/cgi-bin/myfile.cgi',
data: {
x: 1,
today: '20110504',
user: 'Joe'
}
}).success(function(data, status, xhr) {
if (data)
alert(data);
});
That is for jQuery 1.5 or higher. You can run that whenever a certain button is clicked like this:
HTML for the button:
<input type="button" id="doThis"/>
JavaScript:
$(function() {
$('#doThis').click(function() {
//put AJAX sample shown above, here
});
});