Saving the state of various draggables and droppables to create new html - php

How can I save the state of various draggables and droppables (along with their background images) and assign a button to create a new html which adds some of the more features to the existing states?

Your question is quite ambiguous...
Why don't you look into jQuery:
Draggables
jQuery Post
I assume what you are wanting to achieve would need to be saved into a database, so you would use AJAX to then save the positions from the dragable elements

Related

Add item to a list in realtime in a wordpress template

I'm working on a wordpress template and there is one textbox and a button.
I would need to archieve that when i type something in the box and press the button, the page writes this value in the database and then adds a new row to a table on this very same page containing the newely added item. All this without the page beeing reloaded.
As far as I know i need to use jquery to do this, but how is this PROPERLY done inside a wordpress template by using the tools wordpress provides me with?
Even without knowing how wordpress handles custom javascript code, I assume that you can import a custom JS script in the document. (https://codex.wordpress.org/Using_Javascript).
What you need to do is to bind the click event of the button (.click() or with the on() function), and in the callback you can retrieve the value of the text box ($("textbox_selector").val()).
After that you can use the $.ajax() (or the $.get / $.post shorthands depending on which kind of request you need).
To add a new row to the table you can create a new tr element with $("<tr>"), adding the various <td> in the same way or using the html() function to directly set the html inside.
Then you can use the append() function on the table selector.
P.S.: you say that "As far as I know i need to use jquery to do this" so I assume it's only about the client side. Do you need even the server side? If the answer is yes, we need at least the DB structure and other server-side info, and then I can integrate the answer.
Anyway the PHP script will be part of your template and it will be responsible to add the entry in the DB and returning some useful message that will be available in the $.ajax() callback function.

Survey form builder using Jquery PHP?

I'm trying to create a Survey builder wizard that would be embedded in the website.
Users will be able to create their own surveys by dragging and dropping appropriate form elements such as checkboxes, radiobuttons etc
Once the user creates his survey br dragging and dropping the appropriate form elements such as radiocontrol, checkboxes - He should be able to save the created survey and publish it.
While going about doing this I came up with the following questions:
I could build my own drag and drop form building wizard - but is there any open source plugin/code out there so that i dont need to reinvent the wheel ?
How the should the form structure be saved ?
Should the form elements with the associated text be saved in a database (mysql) and rebuilt on the fly when someone accesses the survey link on the mobile ?
Should I be looking at XML/JSON to store the html form structure
Would appreciate any help !
Here is one that we're using now to put a form builder on our client's website.
http://www.botsko.net/blog/2009/04/07/jquery-form-builder-plugin/
The form can be serialized to both JSON and XML.
You can use jQuery UI for the drag and drop operations. I would make use the grid functionality provided.
To save the form I'd make standardized representations of the elements in a JSON format and save those.
This representation should include the left and top css attributes (for positioning) and a subset of styles and attributes which your users can assign their input fields.
Just for completeness
At the time I posted the question, this was not available or else I would have opted for this to build the front end :
http://getfuelux.com/formbuilder.html

Editing information from a MYSQL database from website frontend.

I wonder is someone can help, I'm building a website, which is driven from a database. It will consist of user submitted information.
Currently all the information is pulled from a record in the database and is being output via a PHP echo, what i would like too do is add a feature that would allow me to edit the information if incorrect from the websites front end.
I have seen many websites have some form of edit icon next to information in there databases, when clicking this icon the echoed text changes from text to a text field and you are able to update the field being echoed from the database.
Im a designer so have limited knowledge of how functionality for this kinda feature might work.
please could anyone let me know how something like this might be achieved.
many thanks.
You would need to build some kind of javascript functionality to allow the in-place editing of those data bits. One possible solution is a jQuery plugin like jEditable.
Then you need to build a server-side script in something like PHP or ruby where it would take the submitted information and update the database.
well the process is the same for the front-end and back-end. it depends whether you want you build a password protected editable forms or just editable for everyone.
One way you can do this is
echo your information into text inputs
give them a css class that removes the border and makes it transparent
make it readonly(so someone couldnt tab into it and change it)
add a javascript onclick event that changes the class to a normal
text box that is not readonly
add a javascript onchange event that uses ajax to save the new
information into the database when they are done typing, or press enter
after the ajax is done turn the text box back to the first css class
EDIT also add a onblur event that changes it back as well
you could even change the cursor for the text input to a pointer instead of the default (text) cursor so that is looks like you can click on it.
.
now html5 has contenteditable attribute which you can set for elements
simple example:
www.hongkiat.com/blog/html5-editable-content/
simpler demo:
https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_global_contenteditable

Removing XML data based on divs being hidden using jQuery

Okay this is quite complicated to explain but i'll try and keep it as short as possible. I'm making an 'app', part of the function of which is to pull XML based data from a file using PHP DOMDocument() and a loop to display each block of information in its own DIV. My aim is to allow the user to then click a 'close' button on any of these displayed div's and they will be hidden using jQuery similar to this:
$('input[name=foo]').live('change', function(){
if ( $(this).is(":checked")) {
$('.bar').hide(500);
}
I'm pretty certain I can get it up to this stage with no issues however, when the user saves at the end of this process I want to pass params back that relate to the boxes that have been hidden/removed using $_POST and then subsequently remove the corresponding items/nodes from the original xml document. Each item and each close button has a unique ID.
Any tips on how to achieve this would be much appreicated. thanks
just get the ids or names of the div that have hidden and send that as POST and then go to their parent element. suppose their parent node is referenced in $parent and the node u want to remove is referenced in $child. Now use $parent->removeChild($child)
or u can do this
get the node reference say $node
then use
$node->parentNode->removeChild($node);
One idea is that you can check whether the div is hidden or not like $(".bar").is(':hidden'); and then not include it in the XML you're sending back.
When one of the boxes is clicked, do a xmlhttprequest using the post method.
$.post() pasing the ID and state of the box.

Dynamically update a drop down menu after a user types something that should be added to list

I am creating a website in php with a form that teachers complete to tag each question on a test with a label. The labels are predetermined and listed in a set of drop down menus (one for each question on the test), but there is an option for users to click "add a new label" which pops up a another form in a new, smaller window (while keeping the contents of their original form intact).
Once the user adds their new label, how can I dynamically update the contents of the original drop down menus to include the new label, WITHOUT resetting the dropdown values that have already been set by the user?
You'll need to use JavaScript to do this. JavaScript will allow you to modify the HTML of the web page after it has been loaded and rendered by the browser. If you need to update a database so it is aware of all of the possible drop down options you can use Ajax to send the new option to the server where a PHP script would add it to the database.
Using frameworks like jQuery and Prototype will make this easier to do then using raw JavaScript.

Categories