Well, I have some paragraphs in my php that is coming from a database, and I want the user to have the ability to double click the text or press a button, edit the text, and then save it in database. Is it possible?
Sure you can.
All you need to do is put a submit button that whenever it is clicked you preview a textarea. Then you show the value from the database on the textarea (by SELECT on the SQL command) and then after the 'send' submit button (after the user finished editing) take the value the user wrote by the name of the textarea and put it instead of the text you previewed (INSERT INTO command).
You can avoid using a textarea by setting the contentEditable property to true or false on the element that contain the text.
For example, if the HTML is like :
<p id="sometext">This is the paragraph you cant to be able to edit</p>
You can use document.getElementById("sometext").contentEditable = true; in JS to make it editable - and document.getElementById("sometext").contentEditable = false; to reverse it.
Then you could for example retrieve the innerHTML of the element when done with editing, and send it via AJAX to a PHP processing page (updating into MySQL DB) ^^
Yes, you can. You'd need a textarea with submit button, and then you would take the contents of the textarea and use SQL update to update the database with the contents of the textarea.
A full answer is a tad to broad for Stack Overflow.
Related
I'm using an iframe to get the content of a registration form on a web page, and, as I have to show this registration form inside an HTML app for Android, I'd like to analyse the html inside the iframe to search for input textfields and to use my custom text field as "dummy" or "proxy" for the considered element:
Let me explain better:
As the web page wouldn't give the user the same easy approach as an app, instead of clicking on a textfield and having the problem that the virtual keyboard overlaps the other fields making it difficult to go further.
I want to create a div that covers the iframe and has a text field inside with the same functionality as the one clicked: by this way after entering the text into the dummy field and clicking an ok button aside, the clicked field would be updated and all the other things hidden (virtual keyboard, etc.).
It would be simple if the goal was just to copy a text from a field to another, but the real problem is that the clicked field could have some events like onkeypress or onchange (e.g. to autocomplete) and so on, and I should get the same behaviour on the dummy field.
In an imaginary world I'd do:
document.getElementById("dummy") = document.getElementById("original")
And then destroying and recreating the dummy whenever required.
Do you know if is there something possible to do?
You can't read a div from inside of an iframe after the iframe has loaded. The reason for this is to prevent hackers from making programs that can grab your credit card numbers from web-based forms through iframes and then use the apps to record them.
UPDATE
You would have to retrieve the entire form in the background, then render it again using webkit, then when the person clicks submit, you would have to submit the exact same form data to the host from your device.
Its possible, but I don't see a good reason why you would ever need to use that.
I'm using a form where in a text box is bound to a variable object by its path. I also have a button to fetch few records based on the input given in this text box. When I enter something for the first time and hit the button, it fetches the records. But again if I try to hit backspace or delete buttons inside the text box, it takes me to the previous page instead of simply deleting the text inside. Is there a way out? I tried with events like preventDefault() using keyCode restrictions, but in vain. Please help.
PS: This text box has regex validations and also has logic to pre-populate.
when records are fetched, you lose the focus on your text box. When you press the Backspace key once more, the browser takes you to the previous page (as most browers do). Set the focus back on your element after you fetch the records or change you code so the records fetching will not change the focused element.
See : https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement.focus
This question was probably asked few time by now... but I didn't find any solution in the last 2 days so I'm asking it in here.
I need to inject some text into a textbox that has an ID and I already know it. the scenario is like that:
The user insert a text into the textbox inside my toolbar.
The user clicks on a button in my toolar.
The function in the button should redirect the user to a new page in the background, inject a text into a specified textbox and click a button in that webpage.
Return a link that is generated on the webpage.
I know how to open a new webpage. now all is left is the rest.
I can't seem to inject the text into the specified textbox.
Also to note, I can't use greasemonkey on this project and that's why I will have to write everything I'll need to write.
If you can direct me to the starting point for this problem it would be nice.
The textbox is XUL textbox or html textarea?
It look like your scenario is simulate submit a form in background, why not just directly create a XMLHttpRequest to do this, no need to interactive with UI.
Update:
If it is a XUL textbox, you can use value property
var textbox = window.document.getElementById(textboxId);
if (textbox) {
textbox.value = 'your text';
}
I'm trying to create a page where a title and paragraph are displayed, along with an 'edit' button.
The goal is that the paragraph and title seems like normal text, but when the edit button is clicked, they become writeable fields that the user can edit. When the edits have been done, the user can click a save button and the html is updated.
Is this at all possible?
Furthermore, is it possible to have a 'create' button, that adds a new title and paragraph element that are blank, which the user can fill in?
I'd like to stick to html/javascript/jquery, since this won't be running on a server.
Thanks!
Plugin exists already to provide in-place editing functionnality:
jQuery InPlace Editor
jEditable
I'm trying to make an Invoice Table, later when the customer finishes, I want them to see the same product they ordered in another page!
I tried using HTML post method, but that doesn't work, because I'm using a JScript function to add rows and delete.
So to be clear, I want to know if it is possible to clone, or copy the entire table to another page with the content or without the content?
When you add and remove rows in your table,
you could also add and remove hidden form values for a form.
That form would have a submit button which sends you to the target page.
That target page takes the form values and produces a nice table again.
Either you take the form values with you with those hidden values
or you could store them temporarily in the session...
When users add and remove rows, the data is sent to the server, right? So just display the invoice on the other page. Or maybe I'm misunderstanding the question.