[thelist] Form question

Joe Crawford jcrawford at avencom.com
Sat Mar 24 23:02:06 CST 2001


Michael Galvin wrote:
> Actually, the original mail left a fairly major detail out.  The form
> captures the 'name' in 3 stages (it's the way it has to be done), and so
> when the user presses the button, I want the form to almagamate the 3 fields
> and send them on their way.  I figure JS is the best way, using an
> onclick(), but I've no idea of the actual script.

Hi Michael ...

It occurs to me that the *best* place to handle this is on the server side.
That said, you can assemble a combined form value as below.

<script type="text/javascript" language="JavaScript">
<!--
function assembleName() {
assembled=document.forms[0].p1.value;
assembled+=document.forms[0].p2.value;
assembled+=document.forms[0].p3.value;
document.forms[0].Name.value = assembled;
return true;
}
//-->
</script>

<form action="script.pl" method="get"
    onsubmit="return assembleName();">
<pre>
Part 1 of Name <input type="text" name="p1">
Part 2 of Name <input type="text" name="p2">
Part 3 of Name <input type="text" name="p3">
</pre>
<input type="hidden" name="Name">
<input type="submit" name="submit" value="submit">
</form>

Hope that helps!

    - Joe <http://artlung.com/>

--
Joe Crawford ||||||||||||||       mailto:jcrawford at avencom.com
||||||||||||||||||||||||             http://www.avencom.com
|||||||||||||||||||||||||||      Avencom: Set Your Sites Higher





More information about the thelist mailing list