...

View Full Version : Output html and echo fieldset from form entries



jeeplaw
09-06-2006, 04:01 PM
So I've been playing around with this idea to have a user enter information into your standard online form, something along these lines:

<p>
Send me some comments.
<p>

<form ACTION=" ? not sure? " method="post or get?" >

<HR>
Your name:<br>
<input name="name" type="text" size=60> <br>

<p>
Your email address:<br>
<input name="email" type="text" size=60> <br>

<p>
Your comments?<br>
<textarea name="comments" COLS=60 ROWS=8></textarea><br>

<p>
<input type="submit" value="Send">
<input type="reset" value="Clear">
</form>

Now here's where the javascript comes in for the form handling, but I'm just getting onto the onramp with javascript if you know what I mean. I'd like the javascript to take control of the form data once someone hits submit and then on the next page (or even in a pop up), output the fields and data with the html tags in place so that someone can just cut and paste into an html page and have the questions and the inputted data properly formatted.

Is this doable? Thanks

David

rlemon
09-06-2006, 07:59 PM
So I've been playing around with this idea to have a user enter information into your standard online form, something along these lines:

<p>
Send me some comments.
<p>

<form ACTION=" ? not sure? " method="post or get?" >

<HR>
Your name:<br>
<input name="name" type="text" size=60> <br>

<p>
Your email address:<br>
<input name="email" type="text" size=60> <br>

<p>
Your comments?<br>
<textarea name="comments" COLS=60 ROWS=8></textarea><br>

<p>
<input type="submit" value="Send">
<input type="reset" value="Clear">
</form>

Now here's where the javascript comes in for the form handling, but I'm just getting onto the onramp with javascript if you know what I mean. I'd like the javascript to take control of the form data once someone hits submit and then on the next page (or even in a pop up), output the fields and data with the html tags in place so that someone can just cut and paste into an html page and have the questions and the inputted data properly formatted.

Is this doable? Thanks

David


kinda like a preview popup? or you want the code to be copied exact with the values inserted into the form elements?

jeeplaw
09-06-2006, 08:32 PM
Yea, a preview popup with all the html tags intact and values from the user submitted in the form elements.

So if someone entered:

Your name: Bob Johnson
Your email address: bj@hotmail.com
Your comments: This rocks!

The output would be something like:

Your name: Bob Johnson </br>
Your email address: bjhotmail.com </br>
Your comments: This rocks! </br>

So that if I copied and pasted it into an html code page, the line breaks would be formatted.





kinda like a preview popup? or you want the code to be copied exact with the values inserted into the form elements?

rlemon
09-06-2006, 08:42 PM
Yea, a preview popup with all the html tags intact and values from the user submitted in the form elements.

So if someone entered:

Your name: Bob Johnson
Your email address: bj@hotmail.com
Your comments: This rocks!

The output would be something like:

Your name: Bob Johnson </br>
Your email address: bjhotmail.com </br>
Your comments: This rocks! </br>

So that if I copied and pasted it into an html code page, the line breaks would be formatted.

try this:



<?
if(isset($_POST['Send']))
{
print "Your name: " . $_POST['name'] . "&lt;BR /&gt;\n";
print "Your email address: " . $_POST['email'] . "&lt;BR /&gt;\n";
print "Your comments:&lt;BR /&gt;\n" . $_POST['comments'] . "&lt;BR /&gt;\n";
} else {
?>
<p>
Send me some comments.
<p>

<form ACTION="<?= $_SERVER['PHP_SELF'] ?>" method="POST" >

<HR>
Your name:<br>
<input name="name" type="text" size=60> <br>

<p>
Your email address:<br>
<input name="email" type="text" size=60> <br>

<p>
Your comments?<br>
<textarea name="comments" COLS=60 ROWS=8></textarea><br>

<p>
<input type="submit" value="Send">
<input type="reset" value="Clear">
</form>
<?
}
?>

jeeplaw
09-06-2006, 08:49 PM
Hmm..not quite. After hitting send it just reloads the screen and the fields are empty


try this:



<?
if(isset($_POST['Send']))
{
print "Your name: " . $_POST['name'] . "&lt;BR /&gt;\n";
print "Your email address: " . $_POST['email'] . "&lt;BR /&gt;\n";
print "Your comments:&lt;BR /&gt;\n" . $_POST['comments'] . "&lt;BR /&gt;\n";
} else {
?>
<p>
Send me some comments.
<p>

<form ACTION="<?= $_SERVER['PHP_SELF'] ?>" method="POST" >

<HR>
Your name:<br>
<input name="name" type="text" size=60> <br>

<p>
Your email address:<br>
<input name="email" type="text" size=60> <br>

<p>
Your comments?<br>
<textarea name="comments" COLS=60 ROWS=8></textarea><br>

<p>
<input type="submit" value="Send">
<input type="reset" value="Clear">
</form>
<?
}
?>

rlemon
09-06-2006, 09:08 PM
forgot to add a name to the submit button.

this works

tested on http://rlemon.com/_garbage/test.php (link will be removed later. you can see it there for the time being)



<?
if(isset($_POST['Send']))
{
print "Your name: " . $_POST['name'] . "&lt;BR /&gt;<br />\n";
print "Your email address: " . $_POST['email'] . "&lt;BR /&gt;<br />\n";
print "Your comments:&lt;BR /&gt;<br />\n" . $_POST['comments'] . "\n";
} else {
?>
<p>
Send me some comments.
<p>

<form ACTION="<?= $_SERVER['PHP_SELF'] ?>" method="POST" >

<HR>
Your name:<br>
<input name="name" type="text" size=60> <br>

<p>
Your email address:<br>
<input name="email" type="text" size=60> <br>

<p>
Your comments?<br>
<textarea name="comments" COLS=60 ROWS=8></textarea><br>

<p>
<input type="submit" name="Send" value="Send">
<input type="reset" value="Clear">
</form>
<?
}
?>

jeeplaw
09-06-2006, 10:57 PM
Awesome, works perfectly :) Now, for one final question..is it possible to make hidden text in the form visible once they hit the submit button so that I can put a linkback to my website at the bottom of the form?


forgot to add a name to the submit button.

this works

tested on http://rlemon.com/_garbage/test.php (link will be removed later. you can see it there for the time being)



<?
if(isset($_POST['Send']))
{
print "Your name: " . $_POST['name'] . "&lt;BR /&gt;<br />\n";
print "Your email address: " . $_POST['email'] . "&lt;BR /&gt;<br />\n";
print "Your comments:&lt;BR /&gt;<br />\n" . $_POST['comments'] . "\n";
} else {
?>
<p>
Send me some comments.
<p>

<form ACTION="<?= $_SERVER['PHP_SELF'] ?>" method="POST" >

<HR>
Your name:<br>
<input name="name" type="text" size=60> <br>

<p>
Your email address:<br>
<input name="email" type="text" size=60> <br>

<p>
Your comments?<br>
<textarea name="comments" COLS=60 ROWS=8></textarea><br>

<p>
<input type="submit" name="Send" value="Send">
<input type="reset" value="Clear">
</form>
<?
}
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum