Input value being displayed in HTML

Asked

Viewed 62 times

0

Within a variable PHP have a content HTML. to be shown.

So I did

$htmlPDF = $html;

$html .= "
    <form action='pdf.php' method='post'>
        <input type='hidden' name='htmlPDF' value='" . $htmlPDF . ".</div>' />
        <input type='submit' class='button formularios' value='Gerar PDF' />
    </form><br /><br />
    <button id='btnGrafico' class='button formularios'>Gerar Gráfico</button><br />
    <canvas class='line-chart'></canvas>
";

That one maneuvering is that before displaying the buttons I need to pick up content HTML until then.

The problem:

When I’m gonna show off $html, Besides leaving the content itself once is also leaving the content of variable $htmlPDF that is in

<input type='hidden' name='htmlPDF' value='" . $htmlPDF . "' />

In other words, contained duplicate.

What is wrong here?

Obs.: if I do:

<input type='hidden' name='htmlPDF' value='' />

The contents display normally

inserir a descrição da imagem aqui

  • Already tried without double quotes: leaving only value=' $htmlPDF '

  • yes, it gave the same thing. I added an image!

  • The content is duplicated because you match the $htmlPDF previous content of $html here: $htmlPDF = $html; ... That is, to the variable $htmlPDF is assigned ALL content of the $html previous. Then you concatenate ALL content with the htmlPDF variable that contains all the previous HTML...

  • But how should I put $htmlPDF as the value of INPUT Hidden so that this duplication does not occur? That is the exception of the question and my doubt! And also I do not see in the code any omde dou echo or print in the variable $htmlPDF. You saw where my trouble is?

  • Dreamweaver? @_@

2 answers

0

Have you tried that?

$htmlPDF = $html;

$html .= "
    <form action='pdf.php' method='post'>
        <input style = 'display: none' name='htmlPDF' value='" . $htmlPDF . ".</div>' />
        <input type='submit' class='button formularios' value='Gerar PDF' />
    </form><br /><br />
    <button id='btnGrafico' class='button formularios'>Gerar Gráfico</button><br />
    <canvas class='line-chart'></canvas>
";

I think css can save you on this, I do it here..

  • It didn’t work buddy. It keeps displaying the content. But the input was already Hidden type

0

Solved:

html .= '
    <form action="pdf.php" method="post">
        <input type="hidden" name="htmlPDF" value="' . $htmlPDF . '</div>" />
        <input type="submit" class="button formularios" value="Gerar PDF" >
    </form><br /><br />
    <button id="btnGrafico" class="button formularios">Gerar Gráfico</button><br />
    <canvas class="line-chart"></canvas>
';

It was enough reverse as quotation marks and it worked!

Where was double quotes put single and vice versa.

I just don’t understand why but I did and that’s what matters!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.