Gossamer Forum
Home : General : Perl Programming :

Automatic Form Filling.....

Quote Reply
Automatic Form Filling.....
I saw something simple yet effective the other day and can't for the life of me find it again.

I had to fill in a form and further down the page very similar information was needed but instead of making me re-type it there was a check-box saying "Same as above" and when you checked it the fields were filled with the the correct data from higher up in the form.

Would someone be kind enough to reproduce this for me or tell me where I can find such code. I don't know enough about Javascript myself to attempt it :) - I can only just cope with Perl ad VB/VBS

Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/

Quote Reply
Re: Automatic Form Filling..... In reply to
http://www.javascripts.com
http://www.javascript.com

Regards,

Eliot Lee
Quote Reply
Re: Automatic Form Filling..... In reply to
Hmm I kinda asked for that didn't I.

I had looked though but didn't find it. Maybe I overlooked it.

Thanks

Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/

Quote Reply
Re: Automatic Form Filling..... In reply to
Holy cow - I just spent 10 minutes working on this myself and managed to do it! - hehe.

Code:
<script language="javascript">
<!--

function check() {

do = new Boolean;
do = false;

if (Reg.sab.value == "Yes") {
do = true;
}

if (do == true) {
Reg.name2.value = Reg.name.value;
}
}

//-->

</SCRIPT>
Then I have......

<input type="radio" name="sab" value="Yes" onmousedown="check();">

How satisfying Smile

Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/

Quote Reply
Re: Automatic Form Filling..... In reply to
<script language="javascript">
<!--
fuction check () {
Reg.name2.value = Reg.name.value;
}
//-->
</script>

that alone should work..

Jerry Su
http://www.jsu07.com
Quote Reply
Re: Automatic Form Filling..... In reply to
Oh yes - I didn't think it could be that simple :)

Thanks.

Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/

Quote Reply
Re: Automatic Form Filling..... In reply to
For a dumb like me:

Could anyone post a whole html-sample?

Thanks!


Quote Reply
Re: Automatic Form Filling..... In reply to
Code:
<form name="autofill" action="bla.cgi" method="POST">
Part 1:



Name: <input type="text" name="name">

Email: <input type="text" name="email">



Part 2:



Same as above? <input type="radio" onclick="update();">



Name: <input type="text" name="name2">

Email: <input type="text" name="email2">

</form>
Then in the <HEAD> put:

Code:
<script language="javascript">
function update() {
document.autofill.name2.value = document.autofill.name.value;
document.autofill.email2.value = document.autofill.email.value;
}
</script>
That should work.


Installations:http://www.wiredon.net/gt/
Favicon:http://www.wiredon.net/favicon/