Is there a way that I can capture the values that they used in the form and pre-fill them into the next form so they don't have to type them over again?
Thanks in advance for the help.
$Form{'name'}. so if you have an input with name="color" you can access it's value with
$Form{'color'}. Alternately, if you add this line to the top of the file right beneath the shebang line...
use CGI qw(:standard); ...you can access any form input value from any point in the script using this syntax:
param("name"). HTH
Jordan
Sorry, I misunderstood you, I thought you were trying to get the values so you could generate the HTML dynamically from within the FormMail script. There is no way to get the values with just HTML, AFAIK.
The only know of two ways to make a new form with the values already filled in; the first is to do it from inside the FromMail script...e.g., instead of the thankyou page...
print "Content-type: text/html\n\n";
print <<"(END HTML)";
<form name="form2">
<input name="color" type="text" value="$Form{'color'}"/>
</form>
(END HTML)
The second is to use a GET method on your first form (method="GET"), and then redirect to your HTML page with the new form to fill, then use JavaScript to parse the
document.referrer object, which will contain the form information from the first form, and will look something like... [somewhere.over.there...]
You basically just use the indexOf() and substring() methods to get the different values...for example,
<script type="text/javascript">
<!--
var name = null;
var val = null;
function getVals() {
if (document.referrer) {
name = new Array();
val = new Array();
var ref = document.referrer;
var idx = ref.indexOf("?");
if (idx!= -1) {
ref = ref.substring(idx + 1, ref.length);
}
else {
return "";
}
var arr = ref.split("&");
var tmpArr = new Array();
for (var i = 0; i < arr.length; ++i) {
// tmpArr is multi-dimensional after this,
// first level is name, second is value
tmpArr[i] = arr[i].split("=");
}
for (i = 0; i < tmpArr.length; ++i) {
name[i] = tmpArr[i][0];
val[i] = tmpArr[i][1];
}
return formFill();
}
else {
return "";
}
}
function formFill() {
for (var i = 0; i < name.length; ++i) {
if (name[i] == "recipient") {
document.form2.recipient.value = val[i];
}
else if (name[i] == "email") {
document.form2.email.value = val[i];
}
// etc...
}
}
window.onload = getVals;
//-->
</script>
Jordan