rat Posted May 25, 2010 Share Posted May 25, 2010 I'm fairly noobish and attempting to set up a pedigree-thingy. What I have is a form, where the user fills in all relevant information. This information then gets sent to another page and it shows up brilliantly and -exactly- how I want it in a table. What I want is two buttons on the form, one of them to show a preview of how the pedigree will look like (This I have.), the second button to open a page where you can see the coding for the pedigree, for the users to copy, and this is the part that is a tad over the head for me apparantly, cause I can't get it to work. How do I 1. Create two buttons on the page of the form that do separate stuff? 2. Create a page where I show the code for the table (with the data from users input) Complete solutions appreciated but not expected, pointers to where I can read and learn would be awesome as I've not been able to find what I've been looking for by myself. Quote Link to comment https://forums.phpfreaks.com/topic/202878-showing-html-code-tags-and-a-bonus-button-question/ Share on other sites More sharing options...
mga_ka_php Posted May 26, 2010 Share Posted May 26, 2010 Create two buttons on the page of the form that do separate stuff? one way is: function dothis() { document.myform.submit(); } function dothat() { document.myform.submit(); } <input type="button" onclick="dothis()" value="Do This" /> <input type="button" onclick="dothat()" value="Do That" /> it's a start, research further. Quote Link to comment https://forums.phpfreaks.com/topic/202878-showing-html-code-tags-and-a-bonus-button-question/#findComment-1063430 Share on other sites More sharing options...
ignace Posted May 26, 2010 Share Posted May 26, 2010 Create two buttons on the page of the form that do separate stuff? one way is: function dothis() { document.myform.submit(); } function dothat() { document.myform.submit(); } <input type="button" onclick="dothis()" value="Do This" /> <input type="button" onclick="dothat()" value="Do That" /> it's a start, research further. What?? Why would you need JS for this? It's as easy as: <input type="submit" name="dothis" value="Do This"> <input type="submit" name="dothat" value="Do That"> PHP-wise you need: if (isset($_POST['dothis'])) {/* do this */} if (isset($_POST['dothat'])) { /* do that */} Quote Link to comment https://forums.phpfreaks.com/topic/202878-showing-html-code-tags-and-a-bonus-button-question/#findComment-1063438 Share on other sites More sharing options...
mga_ka_php Posted May 26, 2010 Share Posted May 26, 2010 as i said, one way. this is the thing that came up in my mind. but thanks for the another solution. Quote Link to comment https://forums.phpfreaks.com/topic/202878-showing-html-code-tags-and-a-bonus-button-question/#findComment-1063440 Share on other sites More sharing options...
rat Posted May 26, 2010 Author Share Posted May 26, 2010 Brilliant, I believe my button-issue is solved. Rightio, so my remaining problem is: html tags inside php code. For the preview button I have something like this: if (isset($_POST['preview'])) { echo "<table><tr><td>$somedata</td><td>$moredata</td></tr>etc"; Here I do not want the code to show, only the result. And for the showcode button something such: if (isset($_POST['showcode'])) { echo "<table><tr><td>here's your data!</td><td>more of users input</td></tr>etc", And here I want the code for the result from "preview", possibly in a <textarea> I have definitely confused myself when it comes to learning how to both show the tags and not show the tags, and to use the result from one clicky as the result in the other, not entirely sure I can do that this way. Another option could be to email the html-code for the table to the user, as code. :| Quote Link to comment https://forums.phpfreaks.com/topic/202878-showing-html-code-tags-and-a-bonus-button-question/#findComment-1063451 Share on other sites More sharing options...
ignace Posted May 26, 2010 Share Posted May 26, 2010 if (isset($_POST['showcode'])) { echo '<textarea>', htmlentities('<table><tr><td>here's your data!</td><td>more of users input</td></tr></table>'), '</textarea>': Quote Link to comment https://forums.phpfreaks.com/topic/202878-showing-html-code-tags-and-a-bonus-button-question/#findComment-1063470 Share on other sites More sharing options...
rat Posted May 26, 2010 Author Share Posted May 26, 2010 Thank you! I think I got it working now, it might be a slightly too complicated way I'm doing it, it's a large table so there'll be much typing to do, but at least it works and I've learned lots. if(isset($_POST['showcode'])) { echo htmlentities('<table><tr><td>'); '$data_for_first_column' , htmlentities('</td></tr></table>') etc Quote Link to comment https://forums.phpfreaks.com/topic/202878-showing-html-code-tags-and-a-bonus-button-question/#findComment-1063557 Share on other sites More sharing options...
ignace Posted May 26, 2010 Share Posted May 26, 2010 If you post your script we may be able to give you some tips to cut down on that typing. Quote Link to comment https://forums.phpfreaks.com/topic/202878-showing-html-code-tags-and-a-bonus-button-question/#findComment-1063561 Share on other sites More sharing options...
rat Posted May 26, 2010 Author Share Posted May 26, 2010 Turned out it wasn't all that much, and with some well placed copy and paste it didn't take long. I couldn't make it show up as I wanted in a <textarea> though, so it's just showing up as code now, which is not ideal, but okay. Is there an easy way to get all that code emailed to the user, and have it show up as code? "here's the code": <html><body><table>etc "Click to email the code to self": Magic-clicky-button-that-sends-above-code-to-email Quote Link to comment https://forums.phpfreaks.com/topic/202878-showing-html-code-tags-and-a-bonus-button-question/#findComment-1063782 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.