esoteric Posted August 24, 2011 Share Posted August 24, 2011 Hi, im trying to figure out how to have a form preview something next to the form depending on what options have been selected on a form. So let me explain better what i mean. I want to create a form which is for customers to create a custom product (in this case a nameplate). The options could be something like; letters (what word they want) font type: [few different font names here] font size: [small, medium, large] color: ... So if the customer typed in 'name' in the letters field then it would be displayed in the preview box If the customer then selected a font type, the change would then be reflected in the preview box.. and so on. I hope you understand what i trying to explain. I can just about handle creating the form but i don't know how to have it display what options have been chosen. If this is too much effort would it just be easier to submit this form and then display the data? or is it not too complicated to have it display on the same form before you submit it? I would prefer it displayed on the same page Thanks for any help. Quote Link to comment https://forums.phpfreaks.com/topic/245604-form-with-preview-box/ Share on other sites More sharing options...
xyph Posted August 24, 2011 Share Posted August 24, 2011 This is going to be a combination of JavaScript and PHP I would do this in the following manner. Have an outside PHP file use values in the query string (using $_GET) to generate a preview image you want to display (using imagemagick or GD) Have a JavaScript application in your form page that checks for certain fields in your form to be updated. When the form is updated, the JavaScript will update an img tag beside the form and the outside PHP file will generate the new image. Watch out though. A PHP script that generates images on the fly can be abused to slow down your server. You may want to limit how many requests any given IP can make in 10 minutes or some reasonable time. If you notice the same options being used again and again, setting up a caching script may be useful as well. Quote Link to comment https://forums.phpfreaks.com/topic/245604-form-with-preview-box/#findComment-1261472 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.