i am really stuck here i have been trying and i am posting here hope some one will help me.
i have a html form where i enter my data and before submitting i need to view my data in the html form and if i need changes change it rt there and submit .
i am able to enter data and how do i display the data without submitting.
To preview your form data before posting you have two options basically: the first is to preview it by using JavaScript to dynamically open a new window and then show your data formatted as you want, the second is to post your data to your server and return a new page containing the data you posted but not yet being integrate to your database, this is a kind of confirmation page, whatever is the option there should be a confirmation button to accept or reject the submission and integration of the data in your database.
The second option requires you to create a new page on the server side for confirmation (preview), having all the power of your web server language.
In general, you have a Preview button and a Save (or Post) one.
The Preview button submits the data which is processed by the server-side script (interpreting markup language, or filtering HTML or other stuff) and converted to HTML, then sent back to the user along with the text field with the raw data.
Then the Save/Post button does the same, but saves the data to the database, and similarly output the HTML, without the text field.
A quite generic answer to a quite generic question...
The question that comes to my mind is how this preview would look different from the data entry page. I mean, if the user is supposed to enter, say, name, address, and favorite color, presumably that data is visible on the screen as they type it. What would a preview do? If you're talking about some sort of validation, like color must be on your list of approved colors or some such, then you have two basic choices: You could do the vaildation with JavaScript before sending to the server, or you could send to the server and let it do validation. I would point out that if you do client-side validation, you really should still validate on the server, esecially if there are security or hacking issues. You have no assurance that the data stream sent to your server really came from the page that you sent to the user. The user could create his own page to send data to your server.
The only other thing I can think of is a formatting preview, like here on Stack Overflow where what you type in may include codes that control format. In that case you might want to use Javascript to give immediate feedback, again, like is done here.
perhaps you can have two buttons one as a preview and one as submit so when u preview it sends the form value in a different page and displays it in a format you want.
The submit button will just do the submitting etc. what u plan to do .
hope that helps
Related
Is there a way that I can have a form that submits (via POST) a form element to a PHP script on my server... then have the PHP script re-encode the data and send to another server, as if it came from an HTML form?
I basically need to intercept one of my forms that users will use, so that I can record data (which are lists, nothing confidential or personal information) that the user selects in the first form, then it will be processed by my PHP script, but then I want it to be re-encoded as if it was coming directly from the original HTML form (as I have to submit some hidden fields to the final destination server after my PHP script works with the POSTed form data.
How can this be done? and if someone could give a simple example, I'd appreciate it. Thanks
I am trying to understand if the following scenario is possible:
a .PHP page that has a form and inputs for the user to submit information
The page itself offers several different languages for the user to view it in
The user can change languages but the form and the inputs retain their values (if the user has added information) - so the page cannot be re-loaded (as it would lose the information)
I think this might be achieved using an Ajax solution but I'd appreciate any thoughts or advice.
You actually want to change the page, so reload might still be the best choice. Otherwise you need to change every string on the page with javascript, which can get tedious.
You can do the reload without loosing the data. Just add the language information to the form and send another parameter to avoid the actual action that would normally happen when you send the form on the php side. Render the page in the new language and insert the transmitted data in the form.
I have a database app written in PHP (jQuery/JS on the front end) that has bilingual labels/text. Currently one can only change one's language on a maintenance page (form submission, then PHP updates a session variable with their new language choice), but the users would like me to add a language pulldown that would appear in the corner of all pages. When the page contains a form, I don't want users to lose their partially entered data if they happen to change the language, so I need to save/restore the form data somehow. Is there an easy way to do that? I know I can use jQuery to serialize the form, but then what? Send that added onto the URL and pick it up in PHP? Then what? Write some routine to loop through the form fields and handle them properly (inputs, selects, radio boxes, etc. are all different)? It seems like there should be an easier way. I don't mind restricting myself to HTML5-supported solutions or adding jQuery plugins.
How about localStorage?
If user has filled any input fields, save them to localStorage and delete the data after user submits the form.
My suggestion is to:
Submit the Language and any wanted user data when changing language to the server using $.ajax or $.post
here is the challenge, I have a webpage, with a form in it , and the button that corresponds to it of course causes a submit. The other button that I have, essentially must trigger a database call that displays content from the database, on this page.
So technically my mind understands that this button should send a GET request to the server and then I retrieve the necessary information and it is displayed. But syntactically, I do not understand how to pull this off, one way to go about doing it is to encapsulate this button in another form, that has a method called GET, and in my server side, I retrieve my information, encode it and send it back to the client. But the idea of encoding this inside a form does not appeal to me as this isn't a form, all I really want to understand is how I can trigger the GET method by clicking a button.
Thanks!
There are two simple ways to send a GET request. One is as you figured out, a new form that has that button as an input and nothing is wrong with that so I'm not sure what is not appealing to you. The second way could be via link, for example:
Link
Ok, I know there have been a few questions posted on this but a lot of the information are dotted around and not necessarily connected in one form that I need for my site.
Basically I want to create the style/functionality of the twitter form on their home page.
Where inside the input fields are the labels, and when you click on the input the fields the labels don NOT disappear but fade into a different colour. Its only when you type, is when it disappears.
If they don't type and press submit I want the verification signs come up ( I know how to do this but it seems to be conflicting when I put the jQuery code in)
When all fields are inputted I would like the form to fade and represent a thank you message whilst
the data gets placed into a mysql ( specifically a MAMP/PHP My Admin) database.
Very similar to this form on hbuddy.com
Would massively appreciate if this was responded in a step by step format, simply because i am at the beginning stages of learning pretty complex programming language.
Thanks!
you can try jquery ajax for form submission..
These links will help you for getting started..
http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/
http://www.9lessons.info/2009/04/submit-form-jquery-and-ajax.html
http://www.ryancoughlin.com/2008/11/04/use-jquery-to-submit-form/