jaynesh — 2011-07-16T20:10:55-04:00 — #1
I understand how to reveal content within a div using hover, but how would I reveal content on click.
paul_wilkins — 2011-07-16T21:21:15-04:00 — #2
By using scripting to assign an onclick event to a suitable element, which would trigger a function to reveal the appropriate content.
jaynesh — 2011-07-19T10:26:30-04:00 — #3
Hi, I originally posted this in CSS but it got moved to JS.
I don't know much about JS.
This is what I am trying to do.
I have some data in mysql which is being outputted via php.
When a user clicks 'edit'. the text will be replaced by a form.
paul_wilkins — 2011-07-19T16:08:45-04:00 — #4
Do you want to learn how to do it yourself, or would you prefer to employ someone else to do it for you?
jaynesh — 2011-07-19T16:38:08-04:00 — #5
paul_wilkins — 2011-07-19T16:43:05-04:00 — #6
Then may I suggest that you continue along the PHP path, as that is the way that normally such edit field things are performed.
The edit button (or link) is clicked, which submits as the action and a line number.
The PHP script then creates a new version of the page where the appropriate line number uses a form input instead.
So get the editing side of things working first in PHP, and after that other things can be looked in to.
jaynesh — 2011-07-19T19:06:24-04:00 — #7
Hi, thank you for your response.
I have already created a form which updates the data.
What I want to do is replace the text with the form when a user clicks edit.
(similar to the way it works on this forum. when you want to edit your post it replaces the text with the form.)
paul_wilkins — 2011-07-19T19:18:12-04:00 — #8
When you click the edit button, the web page sends a request to a php script to retrieve the edit panel for that particular message.
Here's the URL that the request is sent to.
What happens though when scripting is not available? You instead go along to this link, where the edit can also be performed.
It is that fundamental basis which underlies the technique that you want to achieve. Start with PHP scripting to perform the base actions that you wish to perform, and only once the you have those fundamental basics working do you use scripting to request the parts that you require from your working base.
jaynesh — 2011-07-19T20:13:05-04:00 — #9
Hi, thank you for your response.
As mentioned earlier, I have already created a query and a form that allows me to edit the data.
What I want to do is when I click the "edit" button the data is replaced with the form, without having to move to another page.
paul_wilkins — 2011-07-19T20:15:52-04:00 — #10
You will need a PHP script that provides the HTML content for the edit section, so that the web page can request that content for the appropriate line.
Once the Ajax request receives that data, you can then place that data in the page where you need it.
The best way that I've found for people to learn how to use Ajax in safe and effective ways is via the book Bulletproof Ajax
jaynesh — 2011-07-19T20:39:08-04:00 — #11
I've managed to replace the text with a form when a link clicked but when I implement this into my output loop in php it replaces the first row, not the row that I clicked edit on.
'<form name="form1" method="post" action=""><p><label for="textarea"></label><textarea name="editpost" id="textarea" cols="45" rows="5"></textarea></p><p><input type="submit" name="editpost_submit" id="button2" value="Submit"></p></form>'