JavaScript to make an action on an input box - javascript

Don't shoot me I'm new to this web programming. I'm an old (and rusty) VB programmer. I've been reading a little about js, php and html. Basically I've never used 3 different languages in one document.
Say I create an input box the user has to enter a value in, using html. Obviously this box is named say
"name First". Can I use js to grab the data in the box to preform an operation.
My idea is that I'm creating a form, I want to be able make copy and paste easier for the user. If I can I want to use js too copy all the data to the systems clip board if they double click on the input box. I'm using php because the form will be interacting with a database.
Thanks

Yes, you can get the data from an input box with Javascript.
Suppose your input field looks like this:
<input id="firstname" type="text">
Then you could get the value of that like this:
var firstname = document.getElementById("firstname").value;
Javascript does not have the ability to interact with the system clipboard directly for security vulnerability reasons. There are some work-arounds using an Adobe Flash component called zeroclipboard, but these won't work if Adobe Flash is not installed. Or, you could simulate your own clipboard (likely using local storage) that would work just on your own site.

Related

I want to add content from my website to the html permanently

I want to build a website in which users can add information, like craigslist. I want the website user to be able to click a button fill out a form and add another box. For instance, if there is a three by three grid and the user clicks on the add button, I want a form to appear, them to fill it out and one more box to be permanently added to the grid. Of course I could make it happen with Javascript and JQuery but it isn't permanent. Thanks:)
You can Implement this using server side languages like PHP /Node JS, ASP.net, Java, Ruby or you can use Local Storage of the browser (this gives limited storage capacity ). read this for more details. link
If you don't already know PHP, you will need to learn it for this. Also, you will need to make sure that you understand how to validate input because letting users add to your database can be a very dangerous thing to do if you don't understand how things like script injection works.

Is is possible to have text placeholders inside a form field (as to prompt the end user to insert a specific format) without the use of javascript?

So basically, the website is javascript free. No javascript at all. Will not be adding javascript.
However, we need to prompt the end user to enter information accordingly to be used in a database that will then connect to software on the network.
As in, there are 2 hyphens preinserted into a form field for a telephone number. This will prompt the user to enter 310-555-5555 instead of 3105555555.
*** I am a translator for a website owner and a web developer. I am not a programmer. I need a simple answer. I dont need you to explain how to do it. I just need to find out if the programmer is capable or if the website owner is asking for something impossible.
Yeah, it is absolutely possible. There are HTML placeholder attributes available which will do your job.
For modern browsers the HTML attribute placeholder already exists and does exactly what you mentioned.
http://caniuse.com/#feat=input-placeholder Browser support is pretty strong nowadays
Side notes that may not be needed after you further clarified you wouldn't be doing the work:
With that said it gets a little bit more involved if you want to have all users get that information and see it (this is in regards to accessibility). Also placeholders disappear after a user starts typing. Not sure if that is an issue.
Having the explanation part of the label as well (styled differently) will make it always visible and readable by different user interaction.
You can use placeholder attribute to prompt the user to insert a specific format and pattern attribute to validate the pattern entered.
<form>
<input type="text" pattern="\d{3}[- ]?\d{3}[- ]?\d{4}" placeholder="XXX-XXX-XXXX">
<input type="submit">
</form>

Access Text Field & Button of any webpage with java

I would like to access any input element on webpage with the help of java.
For example:- lets user has opened any website which contains 2text field & 1 text area and submit button.
So what I want is that, all that field should get typed by my java programs.
I have speech to text converter and it works fine.
So what I want is that if user open a site T would like to type some content then by speaking it self that content should get types on the web page.
Say for example,
Post on facebook.
Search friend on facebook.
Querying text on google without query string, means text must get types on browser and user must realize that text is getting typed as he is speaking.
It is a wrong approach to use java or javascript here, you need to modify the browser itself, for example you can check
https://wiki.mozilla.org/SpeechAPI

Transferring excel data into text fields and buttons on a webpage

I want to transfer my text data (From Excel) into a form and submit it. It takes lot of time to perform this operation.
So I'm looking into automation tool which can do this task for me.
Basically this webpage consists of Text fields and button.
Is there any way to fill the text field and click on button, by using the Tag name of text field and button from excel?
Is this for yourself or for deployment to the web?
If it's for yourself, you could save the excel file as a CSV. You should then be able to find a way to process it into something that JS can understand.
Actually setting the value of a text element is simply done by targeting the element and setting its value=someValue. For example, you could do
var t = document.getElementById("firstTextField")
t.value = "someValue"
You could also use jQuery for that sort of thing.
You don't really need to use the browser at all. The browser and Excel are just UI on top of the underlying data and API definition, you can script this out. The general idea:
Inspect the form you're trying to submit. Find the target, the submit method, and the field names.
Export the excel file to a CSV.
Write a simple script to loop through each record and make an http request that corresponds with the form submission - same HTTP method, same target URL, putting the Excel values in under the appropriate input names.
It's hard to be more specific with the information you've provided.

django add another field via js with one model field

I would like to add "add another field" and "remove field" button in django admin which results in to add/remove a text field respectively. And all these field should be concatenated(separated via some character) and assigned into one model textfield. How could I achieve this?
You're best bet is going to be to use Javascript. Have Javascript create the new field (or remove it) on button click. Let the user fill in the field as they need to. When they are ready to save you'll need to catch the submit (again using Javascript) and concatenate everything into the initial textarea field and then let it submit to the server where Django should handle it.
You'll also have to then have Javascript run on page load to check the textarea and split out the different sections of your textarea.
More or less that is how you are going to have go about it. If you're wanting to have someone write it for you then that would be a whole other discussion.
(I know it's easy to come along and say "why do that, that's not the best way". I often run into constraints where the best way isn't going to work, so I try not to knock others not knowing their constraints.)

Categories

Resources