I am trying to get my output div by submitting the form but it rapidly disappears? - php-5.3

i used //output div//outputcontent js function showDiv(){document.getElementById('divid').style.display='block'}

Related

React form hook - FormProvider not working

I'm trying to use 'FormProvider' to connect the form to a child component input.
I created the exact same sample from the React-Form-Hook Docs and when trying to submit the form, it doesn't recognize the child component input. What I'm missing here?
Here is my code:Sample Code
do this in your parent component where using FormProvider
const methods = useForm();
<form onSubmit={methods.handleSubmit(onSubmit)}>
inside InnerInput(Child)
const {register} = useFormContext

Is it possible to display a Google sheet as HTML without revealing the URL of the sheet?

I know it's possible to display a Google Sheet as HTML using the spreadsheet ID and GID, i.e.:
https://docs.google.com/spreadsheets/d/SPREADSHEET_ID/gviz/tq?tqx=out:html&tq&gid=GID
But in order to view that, you have to know the URL of the sheet. What I'm wondering is whether it's possible to display this HTML version of the sheet but without revealing the URL of the sheet?
Manually
To retrieve a Spreadsheet in HTML format you can export it accordingly by clicking on File -> Download -> Web Page. That will get you a zip file with the HTML of your Spreadsheet that you can rename as you like without revealing the Spreadsheet ID.
With Apps Script
You can also automate this process creating an Apps Script function that for instance gets triggered every time you click on an inserted button (to do this you can simply click on the menu bar Insert -> Drawing and the on the three dots of the top right of this button click on assign script and set it to the name of your function).
The following function will display a modal dialog on the Spreadsheet when run that if the user clicks on Download it will automatically download the zip file with the Spreadsheet in HMTL format. This function has self explanatory comments :
function downloadHTML() {
// Get ID of the Spreadsheet
var id = SpreadsheetApp.getActive().getId();
// Get the download URL of this Spreadshet in format HTML on the background
var url = "https://docs.google.com/a/mydomain.org/spreadsheets/d/" + id + "/export?exportFormat=zip&access_token=" + ScriptApp.getOAuthToken();
// Download when clicked on the button of the opened dialog
var html = '<input type="button" value="Download" onClick="location.href=\'' + url + '\'" >';
// create an HTML output from the given string
var dialog = HtmlService.createHtmlOutput(html);
// Show a modal dialog on the Spreadsheet UI when the function is run with the Title download
SpreadsheetApp.getUi().showModalDialog(dialog, "Download");
}
Reference
createHTMLOutput
showModalDialog

How do I create a message that flashes after an AJAX form returns an error?

I'm using Rails 5. I want to create a message that flashes on my page after I submit an AJAX form and an error comes back. I'm not using twitter bootstrap and would only consider using that if it doesn't screw up any of the other styling I already have. Anyway, on my view I have this
<div id="error_explanation" class="alert alert-success"></div>
and in my controller I have this
displayError('#{error_msg}')
which invokes this coffee script ...
#displayError = (msg) ->
...
$("#error_explanation").text(msg)
As you guess, right now, the message just displays in plain text . I would like it to flash and then disappear. How do I do that?
If you just need the message to fade out after a set amount of time, then change that last line of CoffeeScript to:
$("#error_explanation").text(msg).delay(3000).fadeOut()
If you need something a bit more complex (e.g. don't fade out if hovered, stacked notifications, dismiss button etc), or ready-styled - then you might want to investigate using a JS library such as toastr.
this should help get you started:
show_ajax_message = (msg, type) ->
$("#flash-message").html "<div id='flash-#{type}'>#{msg}</div>"
$("#flash-#{type}").delay(5000).slideUp 'slow'
$(document).ajaxComplete (event, request) ->
msg = request.getResponseHeader("X-Message")
type = request.getResponseHeader("X-Message-Type")
show_ajax_message msg, type
https://www.google.com/search?q=flash+messages+session+rails+ajax
Based on nothing but your coffee script, here's how:
Not familiar with CoffeeScript and its syntax, so here's plain JS code.
setTimeout(function() {
$('#visitLink').hide()
}, 2000);
That'll make the message disappear after 2 seconds.

Read DIV from string

I need to read a specific HTML of a div that is loaded in a webview
doc = web.stringByEvaluatingJavaScript(from: "document.body.innerHTML")!
With the above code I get the HTML in the webview and turn it into a string
Now I'm trying to get a particular div that HTML
<div id="status_load" name="status_load">DESLIGADO</div><p>Luz <button>Ligar</button> <button>Desligar</button></p>
I tried to do so, but do not return anything!
web.stringByEvaluatingJavaScript(from: "document.getElementById('status_load').value")!
Does anyone know how to do this?

Dynamic Content Loading - HTML5 is OK, Dojo is not

I've got a situation where I am loading DIV's dynamically from a server with dojo.xhrGet. All that is fine. The content comes back fine, and the DIV is inserted into the page fine. Note that in this situation, I cannot know the DIV to load prior to some other event occurring.
The problem seems to be that DIJIT widgets contained within the dynamic DIVs aren't DIJIT widgets, but run-of-the-mill HTML widgets. That is, I can work on them using "dojo.byId('widgetID')" and use standard JavaScript, but if I try "registry('widgetID')", I get an "undefined" response.
How can I get dynamically loaded and otherwise declarative DIV code to be parsed into true DIJIT widgets?
You need to use dojo/parser after your markup div has been loaded to your DOM.
The function parse() will transform your HTML markup from div to a dijit widget if the markup has been decorated properly.
By the way dojo.xhrGet is Deprecated and you should use dojo/request/xhr instead.
Below and example with some pseudocode:
require(["dojo/request/xhr", "dojo/dom-construct"], function(xhr, domConstruct){
xhr("example.json", {
handleAs: "text" // or whatever
}).then(function(data){
// place your div to the dom (data is an html markup similar to this <input data-dojo-type="dijit/form/TextBox" type="text" name="dept1" />)
var targetDom = 'targedDom';
domConstruct.place(data, targetDom, 'replace');
// trasform your div to a dijit widget
parser.parse(dojo.byId(targetDom)).then(function(){
// after is parsed do smt here
});
}, function(err){
// handle the error condition
}, function(evt){
// handle a progress event from the request if the browser supports XHR2
});
});

Resources