Jump to content

Using Javascript and the POST array???


kansasakki

Recommended Posts

Hello,

 

I am wanting to send a field that has been updated to a check.php.  check.php should then generate an updated image of a check.  I would like the image when it is updated to be in an iframe on the same page.  My thoughts are to pass this to the via the $_POST array.  Can this be done without ajax? 

 

I have looked for a couple hours trying to find a possible solution, but none seem to fit the bill.  Any help is greatly appreciated.

 


<html>
<head>
<script src='myjs.js' type="text/JavaScript">

</script>
</head>
<body>
<form id="updateCheck" method="post" action="check.php">
	Sponsor: <input name="sponsor" onChange="updateSponsor(this.value)"><br />
	Date: <input name="date" onChange="updateDate(this.value)"><br />
	Payee: <input name="payee" onChange="updatePayee(this.value)"><br />

</form>
<iframe src="check.php" id="newcheck" height="460px" width="910" frameborder="1"> 
	<body>

	</body>
</iframe>

</body>
</html>

 

Thanks,

Kansas

Link to comment
https://forums.phpfreaks.com/topic/234800-using-javascript-and-the-post-array/
Share on other sites

well I figured it out a bit finally.

 

<html>
<head>
<script type="text/JavaScript">
function submitform()
{
document.forms["updateCheck"].submit()
}
</script>
</head>
<body>
<form id="updateCheck" method="post" action="check.php">
Sponsor: <input name="sponsor" onChange="submitform()"><br />
Date: <input name="date" onChange="submitform()"><br />
Payee: <input name="payee" onChange="submitform()"><br />
Amount:<input name="numamount" onChange="submitform()"><br />
Memo:<input name="memo" onChange="submitform()"><br />
Signature:<input name="signature" onChange="submitform()"><br />
</form>

<iframe src="check.php" id="newcheck" height="460px" width="910" frameborder="1"> 
<body>

</body>
</iframe>

<body>
</html>

 

I can see the post array now holding the values that have been submitted. 

Any thoughts on getting the values to now be placed in the iframe element ?

 

Thanks

 

Kansas

yes, but I needed each element to update dynamically if you will.

 

I have gotten this to work finally.  here is the code in action

 

I am working on implementing a php class to write out the numbered amount for the text amounts on the image.

http://www.novacontech.com/~jeremy//check/check.html

 

Thanks

Kansas

finished code.


<html>
<head>
<script type="text/JavaScript">

function submitform(){
	document.forms["updateCheck"].submit()	
}
</script>
</head>
<body>

<form id="updateCheck" method="post" action="check.php" target="newcheck">
Sponsor: <input name="sponsor" onChange="submitform()"><br />
Date: <input name="date" onChange="submitform()"><br />
Payee: <input name="payee" onChange="submitform()"><br />
Amount:<input name="numamount" onChange="submitform()"><br />
Memo:<input name="memo" onChange="submitform()"><br />
Signature:<input name="signature" onChange="submitform()"><br />
</form>

<iframe src="check.php"name ="newcheck"id="newcheck" height="460px" width="910" frameborder="0">
<head>
<script type="text/JavaScript">
</script>
<head>
<body>

</body>
</iframe>

</body>
</html>

 

check.php

<?php
require_once ('class.number2word.php');

// array from posted input
$newimage = imagecreatefrompng("dream_scenes_check.png");
imagealphablending($newimage, true); // setting alpha blending on
imagesavealpha($newimage, true); // save alphablending setting 
$color = imagecolorallocate($newimage, 0, 0, 0);
$font = 'arial.ttf';
$datefontSize = "14";
$payeeFontSize = "18";
$NumamountFontSize = "24";
$sigFontSize = "15";
$fontRotation = "0";


if (isset($_POST['sponsor']) || isset($_POST['date']) || isset($_POST['payee']) || isset($_POST['numamount']) || isset($_POST['memo']) || isset($_POST['signature'])){
/* Check Text To be written */
if ($_POST['sponsor'] > ''){
	ImageTTFText($newimage, $payeeFontSize, $fontRotation, 45, 105, $color, $font, $_POST['sponsor']);
}
if ($_POST['date'] > ''){
	ImageTTFText($newimage, $datefontSize, $fontRotation, 625, 105, $color, $font, $_POST['date']);
}
if ($_POST['payee'] > ''){	
	ImageTTFText($newimage, $payeeFontSize, $fontRotation, 180, 210, $color, $font, $_POST['payee']);
}
if ($_POST['numamount'] > ''){
	ImageTTFText($newimage, $NumamountFontSize, $fontRotation, 715, 210, $color, $font, $_POST['numamount']);
	// need to creat class & make the $_POST['textamount']
	$instance = new number_word();
	$words = $instance->number_word($_POST['numamount'],0,0);
	//ImageTTFText($newimage, $datefontSize, $fontRotation, 55, 270, $color, $font, $words);//$_POST['textamount']);
	//ImageTTFText($newimage, $datefontSize, $fontRotation, 55, 270, $color, $font, $_POST['textamount']);
}
if ($_POST['memo'] > ''){
	ImageTTFText($newimage, $datefontSize, $fontRotation, 110, 360, $color, $font, $_POST['memo']);
}
if ($_POST['signature'] > ''){
	ImageTTFText($newimage, $sigFontSize, $fontRotation, 560, 360, $color, $font, $_POST['signature']);
}

// Output the image to the browser
header("Content-Type: image/PNG");
ImagePng ($newimage);
imagedestroy($newimage);	
}else{
// if no $_POST values, write the blank image
header("Content-Type: image/PNG");
ImagePng ($newimage);
imagedestroy($newimage);
}

?>


<?php
require_once ('class.number2word.php');

// array from posted input
$newimage = imagecreatefrompng("dream_scenes_check.png");
imagealphablending($newimage, true); // setting alpha blending on
imagesavealpha($newimage, true); // save alphablending setting 
$color = imagecolorallocate($newimage, 0, 0, 0);
$font = 'arial.ttf';
$datefontSize = "14";
$payeeFontSize = "18";
$NumamountFontSize = "24";
$sigFontSize = "15";
$fontRotation = "0";

/* Check Text To be written */
if ($_POST['sponsor'] > ''){
ImageTTFText($newimage, $payeeFontSize, $fontRotation, 75, 105, $color, $font, $_POST['sponsor']);
}
if ($_POST['date'] > ''){
ImageTTFText($newimage, $datefontSize, $fontRotation, 625, 105, $color, $font, $_POST['date']);
}
if ($_POST['payee'] > ''){	
ImageTTFText($newimage, $payeeFontSize, $fontRotation, 180, 210, $color, $font, $_POST['payee']);
}
if ($_POST['numamount'] > ''){
ImageTTFText($newimage, $NumamountFontSize, $fontRotation, 715, 210, $color, $font, $_POST['numamount']);
// need to creat class & make the $_POST['textamount']
$instance = new number_word();
$words = $instance->number_word($_POST['numamount']);
//ImageTTFText($newimage, $datefontSize, $fontRotation, 55, 270, $color, $font, $words);//$_POST['textamount']);
//ImageTTFText($newimage, $datefontSize, $fontRotation, 55, 270, $color, $font, $_POST['textamount']);
}
if ($_POST['memo'] > ''){
ImageTTFText($newimage, $datefontSize, $fontRotation, 110, 360, $color, $font, $_POST['memo']);
}
if ($_POST['signature'] > ''){
ImageTTFText($newimage, $sigFontSize, $fontRotation, 560, 360, $color, $font, $_POST['signature']);
}

// Output the image to the browser
header("Content-Type: image/PNG");
ImagePng ($newimage);
imagedestroy($newimage);	


?>



 

 

Big thanks to Crayon Violet for his image tutorial on this site.

Kansas

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.