Jump to content

Can you set the value of a hidden variable when submitting a form?


DeX

Recommended Posts

Here's my PHP form code:

 

					<form method='POST' action="<?php basename($_SERVER['PHP_SELF']);?>" onSubmit="return stripInputBoxes(1)">
					<?php
						echo "<div id = 'purchaseOrderRow1' style = 'display:none;border: 1px solid black;'>";
						echo $integrityBuildingProductsPDF;
						echo '<input type = "hidden" id = "pdf1" value = "" name = "pdf1" />';
						echo '<button name = "savePurchaseOrder" type = "submit">Save Purchase Order</button>';
						echo "</div>";
					?>


				</form>

 

Here's my Javascript:

function stripInputBoxes(pdfNumber)
{
if (!document.getElementsByTagName) return;

for (i = 0; i < document.getElementById('tableBody').getElementsByTagName('tr').length - 3; i++)
{
	document.getElementById(i).parentNode.innerHTML = document.getElementById(i).value;
}

document.getElementById("pdf" + pdfNumber).value = "ljkasdkljf";

	return true;
}

 

Will this set the value of the hidden variable? I'm trying to echo the value of $_POST['pdf1'] but it comes out to nothing when the page reloads. How do I do this?

What I'm trying to do here is display a purchase order on the screen and the user can edit the quantities in the purchase order. They click SAVE to save the new updated quantities and it auto generates a PDF that's saved on the server with those new quantities. The problem is I need to run the stripInputBoxes function to take the <input> tags out of the HTML code before creating the PDF because the PDF generator doesn't recognize the tags.

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.