Where's no problem using an event to call an ajax call for a data saving function (saveData), but timed, automatic data saving by calling this function at different interval failed without error. See code below. Know why?
<form id="biz" name="biz" action="CGI.script" method="post" onSubmit="console.log('submit button, not save button, clicked'); if (document.getElementById('field1').value=='$'){alert('Liability is required');return false} else if (document.getElementById('field2').value=='$'){alert('Fee is required'); return false};">
// use jQuery to send form save data via ajax call
...
// it works fine
return false
}
</script>
Intention: As the names suggest, "Save & Continue" is supposed to save the data and the form stays on while "Save & Exit" is supposed to send the form to be processed (and we leave this page).
Use Scenario and Problem Statement: If I load the page and enter some data and click on the "Save & Exit", fine, it works as expected. But if I enter/edit data, click on "Save & Continue" (jQuery ajax call works fine to save data and stay on the page), and but then, after more data entry/editing click on "Save & Exit", it triggers the "Save & Continue" event instead of submitting the form and leave the page.
And please note, I can find distance between g11 and G1 but for the distance between g11 and beforeG1 it generates the infamous "Cannot read property 'id' of undefined" error.
jquery-3.2.1.min.js?_=1501353680880:2Uncaught TypeError: $(...).on is not a function
at HTMLDocument.<anonymous> (<anonymous>:3:25)
at j (jquery-3.2.1.min.js?_=1501353680880:2)
at k (jquery-3.2.1.min.js?_=1501353680880:2)
Switch to jquery-1.8.0.min.js resulted in the same.
In the meantime, it's only half of a real function, that is, we need to upload the dropped file onto the server as well.
I've looked at some samples on form data passing with with $.post() function, however, I'm stumbled with two issues. (1) for regular form data, it can be handled like $('#formID').serialize(); but in this case, the form data is a file, which can be a PDF, a Word doc or Excel or image or other types of file. (2) how to map the the DIV with ID of "dropFiles" to the FORM element of type "file"? (3) at form post, the state should be the form processing outcome.
// create form and file element var fm = document.createElement('form'); fm.id = 'myfrm'; fm.enctype = 'multipart/form-data'; fm.method = 'post'; var el = document.createElement('input'); el.type = 'file'; el.name = 'myfile'; // following syntax is incorrect el.value = document.getElementById('dropFiles').innerHTML; // send form $.post('processFileUpload.cfm?data=',$('#myfrm').serialize()); // to upload file to server
Upon date selection from datepicker, user would tab to next field and the onblur event would trigger an action to populate selected date in the SPAN with ID of "dated". However, upon date selection, the cursor simply disappears and if I move cursor using mouse to the next field, the SPAN with ID of "dated" is still not populated with datepicker date. What gives?
After a user selects a date via datepicker he/she continue to type something after the date. Thus, it's very desirable to make the datepicker date selection screen disappear upon selection. Doable? The doc is not obvious on this. If so, how?
The documentation seems to indicate, altFormat:"MM dd, yy" would return April 07, 2017 for today, but it actually returns "04/07/2017", what's going on? Did I misread its doc?
For a jQuery UI's datepicker field and I'd like to add a static timestamp to a selected date value upon date selection. I've looked at all the attributes for datepicker, however, none seems appropriate for this need.
And I attempted to trigger onblur and onMouseout respectively to call up a function to append the static timestamp, however, it quickly shows up and then disappear. So, what to do this? And I wonder if there's a special event, which essentially kicks off after all other events are done...
The line 13 in the code below attempts to reset an onclick event first to null and then on line 14, attempts to set it to another action, however, it's ineffective and how to do it? Thanks.
Line 1: var config = function() {
Line 2: // display config / usage info but no dupe display
Line 3: if (!document.getElementById('confinfo')) {
Line 4: var i = document.createElement('info');
Line 5: i.id = "confinfo";
Line 6: i.style = "color:green";
Line 7: i.innerHTML = conf.usage;
Line 8: document.body.insertBefore(i,document.body.firstChild);
Line 9:
Line 10: // hide the config / usage info to free up the real estate
Line 11: var h = document.getElementById('usage').value = "Hide config / usage instructions";
Line 12: console.log('from top section: ' +h);
Line 13: h.onclick = null;
Line 14: h.onclick = function () {
Line 15: console.log('hide clicked');
Line 16: // document.getElementById('confinfo').style.display = "none";
Line 17: document.getElementById('confinfo').innerHTML = '';