Jump to content

Showing html code-tags, and a bonus button question


rat

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 */}

Link to comment
Share on other sites

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.  :shrug:

Another option could be to email the html-code for the table to the user, as code. :|

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.