Populate a registration form with Tab Delimited Data - html

I have a Tab Delimited Data lets say Name Address DOB EmailID copied to clipboard, now I need to paste this data on some online html forms which contains these fields,but whenever I am trying to do so its pasting all the contents in selected text box, where as if I try the same in excel its recognizing the tabs and placing each filed properly in a different cell.
Do I need to format my input data some other way, please let me know.

It's a little bit difficult to tell when someone pastes data into a field. I believe that only IE and Safari support the onpaste event [source]. For everyone else, you could just check the keypress event.
Anyway, if you can find an appropriate event to latch onto, just check the value of the element, and if it contains tab characters, split the value on that and populate the remaining fields.
document.getElementById('first_field').onpaste = function() {
var cells = this.value.split('\t');
if (cells.length > 1) {
// loop through 'cells' and put the value into the other fields
}
};

I'm not sure this is possible without a bit of programming (creating html forms to post), I wouldn't normally recommend it but if you are not familiar with any programming constructs you might want to check out autohotkey, you might be able to get it to mimic your copy and paste action. If you want a real solution, just holler.

Related

Google Sheets - Track Current Cell Selection?

How to Get the currently selected cell/range? was asked 3.5 years ago, but I'm hoping maybe some progress was made since then.
I'd like to make an interactive spreadsheet where there's a boolean grid that will display more information about the status of the currently selected cell in a static location, allowing users to quickly navigate using the arrow keys.
Referencing the previous instance of this question, I tried using the custom function below to get the cell address, although this isn't very dynamic.
function currentCell() {
return SpreadsheetApp.getActive().getActiveRange().getA1Notation();
}
When testing, this function returns the address of the cell the function is called from. I've tried pressing F5 while highlighting another cell and nothing happened. I've also dragged the formula across a selection and each cell only contains its own address (according to the documentation, it should contain the range).
I've also read Henrique's post on caching from 2012, and while I don't completely understand it, I get that we could not get scripts which update without edits being made or manual formula updates.
I would ideally like for the current cell to be tracked without any extra prompts from the user besides arrow key navigation or clicking to select a cell, but if pressing a non-altering key (like Enter) would allow for tracking, that would be fine. I also only need the selected cell, rather than a range, if that makes things easier.
Explicit Question: Is it possible to track the position of the currently selected cell in Google Sheets and store that position in a separate cell? If not, is there a way to do this without altering cell values?
EDIT: Adding an example for clarity. In this conceptual example, A2 =currentCell() as described above. If I were to hit the right arrow key, A2 would update to display I4, since it is now the current selection.
EDIT2: Jason Allshorn's response to Google app script monitor spreadsheet selected ranges appears to give a way of displaying the current selection (range) on the HTML input text. I'd like to do this, but store the value in a static cell on the sheet rather than input text. I'm new to scripting in Sheets and really only know what I've found for resolving this issue, so if I'm overlooking something, please let me know. I did look at Jason's example sheet and it wasn't clear to me what was actually happening there.
You will have to apply the technique suggested on How do I make a Sidebar display values from cells?. This consist on using using client-side code to constantly pulling values from the spreadsheet and then do the corresponding task.
One approach is to use a side-panel with an input field to set the cells to be tracked and another input field to set the destination cell.
You will have to use the onSelectionChange event in the app script to capture any selection change and then get the range name and put it in desired cell.
Something like the below:
function onSelectionChange(e) {
const range = e.range;
//Return in case of multi cell selection
if(range.getNumRows() !== 1 || range.getNumColumns() !== 1) return;
SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange("A2").setValue(range.getA1Notation());
}
You can see the official documentation here

click through several links on webpage and extract information from each?

I have access a webpage with a list of several hyperlinks, each of which are unique. This is it:
webpage I have access to that lists names from top to bottom. Each name is unique and is a hyperlink. I would like to click on these hyperlinks one by one and extract info from the resulting webpage.
Say I click the first name, say Adam, it then brings me to the following webpage:
alt:this is a page of the user's profile and includes info such as name, email status and more
My goal is to create a program that clicks the name at the top, and then takes the email address and puts it in an excel spreadsheet on my local machine. And then goes back to the original page, clicks on the name directly below the name that was previously clicked on, and then takes this names resulting email and throws it in the spreadsheet.
for those looking at the pictures, i would like to click on 'Adam' and then put his email into a spreadsheet, then go back, and then click on 'Adrian' and then put his email into a spreadsheet, and so on and so forth down the list.
What do I need to do/learn to create a tool that will do this for me?
I know a bit of Java and a tiny bit of html. I've been trying to look for a solution but the most I can get is excel vba to click on the first name, but not much more. Even if I got the vba to click on all the names, it seems I would have to type in an instruction for the vba to find each unique name, and I dont see much point in doing that since its probably faster to just do this manually then.
As i'm not a programmer (but would like to be soon :)) I have had some trouble asking this question since I don't know any technical terms.
Any thoughts/advice on how to do this?
With javascript and a little php you could make this happen. Since it appears this is something running in the browser it would probably be your best bet.
Make your program click links js has the ability to activate links. You could
click on body load
the first link on the page,
then have a counter that counts each time you click a link.
`Find out how many links there are in the document:`
var x = document.links.length;`
`Get the URL of the first link (index 0) in the document:`
`var x = document.links[0].href;`
Click the link you want to click
$(function(){
$('#myLink').trigger('click');
})
now that your on the next page you need to grab the email address that is on this page. If you know the css just grab the string that is in the element. at this point you can use javascript to go back to the previous page.
<button onclick="goBack()">Go Back</button>
Now you are on the original page. Your counter is one number higher. Use the counter to click the next link and your program will repeat the process pushing the new email to your array.
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");
once the program runs out of links to click or hits the limit of your counter you will need to create a txt file with javascript. write your array to the file with PHP. You can do this with an ajax call.
make an AJAX call to your php file passing the array. php can then write to the file.
Here is an example of making a text file and writing to it with javascript
Following this logic you can fairly easy make an application that activates the links in order of a page, pushes the email address to an array as a string. Goes back to the previous page and continues the process till you have all the links. At this point your program will write all the data in the array to a file.

General assistance in Google Apps scripting

OK, I'm tired of searching for specific questions to help with a project, finding answers, changing my implementation which just adds more questions, realizing there's a better way to do things, etc. So allow me to ask for general assistance, I will then do my best to research how to do it and ask further questions if needed.
I'm writing a script to be used as a Gadget in a Google Site page
(I'm more than willing to share this if anyone wants to take a look
at it); right now I'm doing this just for me, but I want to write
this to be easily used by others.
This will list all user's Google Docs in a specified folder; when
selecting the document from the list, the contents will be displayed
for editing in another field.
The user will be able to define certain lines, starting wit a period,
to "mark" as chords that can be automatically transposed with the
push of a button; that is to say, the user clicks a button and all
A's go to A#, B to C, C to C# and so on, but only on the specified
"Chord" lines.
The user can then save this document back to the Google Docs for
printing if needed.
I've got the layout mostly. Some problems I'm coming across:
Doing a .find apparently finds all documents that have the given string in the name and
the contents. The fix would be to put the document IDs in a Hidden, but it doesn't seem
that a List returns the numbered item you clicked on, so how can I also get the ID
that's stored somewhere else?
I'd like the TextArea to be rich text for bolding and what-not; does
Google Apps have a text editor (it'd be awesome if I could just put
the Google Docs editor in a panel)? RichTextArea has been
deprecated, is there a replacement?
To do the transposing, I was planning on just putting every character
of the text area into an array, stepping through the array, when it
sees a "\n" followed by a "." to flip a var "on", then changing any
following characters, then if it sees another "\n" to turn the var
"off"; is there a better way to do this?
Or, is there way to add a script to a Google Document that would do
the transposing (I know you can do macros for spreadsheets, but there
doesn't really seem to be an equivalent for documents)? That way I can
just give out this macro and tell people to use on their existing document.
Since you asked, yes, separate questions would be appropriate, because the combination of questions is very specialized, while the individual problems might be more general, and of use to more people. But let me take a stab at it anyway...
[With the result of find()]... how can I also get the ID that's stored somewhere else?
DocsList.find() returns a list of File objects. Class File has a getId() method that returns the document ID you are used to seeing in Google Drive. To get the IDs of all your files:
var files = DocsList.getAllFiles();
for (var i in files) {
Logger.log(files[i].getId());
}
You should also look at DocsListDialog for creating a file picker that works on Google Drive.
RichTextArea has been deprecated, is there a replacement?
No, not in apps-script. You've just got TextArea. However, you may be able to embed a third-party rich text editor in your UI.
To do the transposing, ... is there a better way to do this?
Change the TextArea.value into an array of lines, then manipulate those, without needing to manage an on/off state. See How do I get information out of TextArea in Google App Script on the button click? and Javascript: Convert textarea into an array.
// aTextArea contains user's input. Probably a Johnny Cash song.
var inputText = e.parameter.aTextArea;
var inputLines = inputText.split('\n');
for (var i in inputLines) {
if (inputLines[i].charAt(0) == '.') {
// Transpose
}
}
// Put lines back together, if you wish
var outputText = inputLines.join('\n');
..is there way to add a script to a Google Document that would do the transposing...
Yes (capability extended to Docs and Forms since question was originally asked). No, Spreadsheets are the only document type that can be a container for scripts at this time.
Alternatively, you could employ a stand-alone script to operate directly on Docs! Perhaps with a script deployed as a Web App that lets users pick the target music to transpose from documents on their Google Drive, and that then writes a new copy of the document, transposed?

How to get text from textbox in GAS?

I run my GAS as an Apps-script-gadget on my web-page and use the GUI-builder. I have two questions:
1.
I know how to set text in a textbox:
app.getElementById("TextBox1").setText("BigSister");
But how do i get text from a textbox?
I tried:
app.getElementById("TextBox1").getText();
...getValue();
...value;
etc.
Nothing works...
2.
Is it possible to print a message window from the code to the screen f.Ex. for debugging purposes?
Any advice would be appreciated.
Within your handler code, you can access the value of the text box as
var value = e.parameter.TextBox1 ;
Before doing this you must have run the setName() method on your text box.
var tetxbox1 = app.createTextBox().setName('TextBox1');
I suggest you run through some of the tutorials at https://developers.google.com/apps-script/articles where you can find answers to many of your questions.
You can retrieve the value of your ListBox when it is passed back through a handler. It's passed in the parameter class under the Id of the ListBox. The following is a fool-proof method of retrieving that value:
function changeHandler(e)
{
var source = e.parameter['source']; //source is your Id of the element
var value = e.parameter[source]; //value is the selected item as ['a' | 'a,b,c']
//More code here
}
I'm still waiting for a solution to retrieve that value without a handler.
EDIT here is a workin example for you to test
online test
and the script + GUI is here
=======================
Srik answer is absolutely right - as usual ;-) - but to make things a bit more clear to you since you are using GUI builder here is a small screen capture that shows the relevant parameters.
As for your second question, the simplest thing to do to get a momentary showing window to 'print' some data to screen is to use a texBox or a textAreal (or anything else that allows to show text...) and play with the setVisible(true) & setVisible(false) to show/hide the widget. In the GUI builder you can put it anywhere in your UI, even over other elements that you normally use since it will be invisible most of the time (the visibility parameter is available in the GUI builder environment as well). It will behave exactly as a 'popup' in other environments...

How do I copy a populated field, say a "company" name from one web page to another?

I want to copy (populated) data, say a "company" name from a form, to another form, and/or web page. This (populated) data field changes, based on what the client enters, however, the resulting data is always a "company".
Is there code I can paste into my HTML document to do this?
To better clarify what I want to do, please see as follows:
("To: ____")
This is on the top half of my web page in a word document contained in a form.
("Bandera") is the company name.
This is on the bottom half of my page in a word document contained in another form.
All I want to do is copy the "company" name (in this case Bandera) to the "To:___" on that form.
I only mentioned the fact that the company name "Bandera" changes, in case this has any affect on the issue.
I am not a programmer and do not know any languages, so I am looking for the easiest way (a code I can paste into my HTML document) to accomplish this.
Thank you,
Michael
This doesn't look like a problem with a simple cut and paste solution. Since you haven't specified what technologies you're using, i'll keep it generic. Two options that I see are:
Have the user submit the form, take the entered value on the server side and set it as a value/default in the resulting (your other) form that you return.
If you're just looking to populate another form on the same page, you can hook the onblur/onchange event of the input control with javascript and populate the value of a second form using something like the dom/javascript function GetElementById or GetElementByName.
Hope this helps point you in a useful direction.
It sounds like you are referring to a data-bound fields?
I am assuming further that the Company is populated from a database as an ID/Name hash/datatable.
If you are using ASP.Net, there a few options of which some are: storing your key for the data-bound field in Session, moving it across to another page using inline variables, or storing the selected Id against a user details table, and retrieving the ID on the other web-page.