Skip to main content
July 12, 2006
Answered

Forms - User and parents address the same

Hi ,

I have a form to input a club members details including their address. The club member is a child and so there is a related parent/guardian address table. My question is, how do I get my form to autofill the parent /guardians address if it is the same as the childs address so that the record can be submitted to my database without having to fill in the address twice?

I have seen forms with tick boxes to say the address is the same for delivery as for cerdit card holder for example. How is this done please? Any guidance appreciated.

Thanks

Jules

I am using ASP with MS Access.
This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer
July 12, 2006
Hi Guys,

Thanks. Yes the Javascript route is the way for me. Thanks for your input. Appreciated. Jules

4 replies

Inspiring
July 12, 2006
> I have a form to input a club members details including their address. The
> club member is a child and so there is a related parent/guardian address
> table.
> My question is, how do I get my form to autofill the parent /guardians
> address
> if it is the same as the childs address so that the record can be
> submitted to
> my database without having to fill in the address twice?

Your database should probably look something like this:

ID
child
parentID
Name
Address

child would be a bit/boolean field.

If the person is a child, then they'd check 'MY PARENT IS A MEMBER' and then
type in their parent's ID or some other way to identify the parent.

Then, in your DB, you'd list the ID of the parent record in the 'parentID'
field.

When you bring up the form, if child = true, then just grab the address from
the parentID record.

> I have seen forms with tick boxes to say the address is the same for
> delivery
> as for cerdit card holder for example. How is this done please?

That would require that the parent is filling out the form at the same time.
Is that correct?

If so, you don't actually need to have two sets of fields. Just have a check
box that says 'address is the same as parent'. If that's checked, ignore the
address fields for the child. You could also set those fields to 'disabled'
or hide them via javascript when that check box is checked.

Here's some sample code for that:

html:

<input id="cbx_sameAsParentAddress" type="checkbox"
name="sameAsParentAddress" checked="checked"
onclick="toggleDiv('cbx_sameAsParentAddress','div_childAddress');" /><label
for="cbx_sameAsParentAddress">Address is same as parent's address.</label>
<div id="div_childAddress" style="display: hidden;">
(put child address form fields here...
</div>

javascript:

<script language=javascript type=text/javascript>

function toggleDiv(idOfToggler, idOfToggled) {

if(document.getElementById){
if(document.getElementById(idOfToggler).checked==true){
document.getElementById(idOfToggled).style.display='block'
}
else{
document.getElementById(idOfToggled).style.display='hidden'
}
}
}

</script>-Darrel


Translate
Inspiring
July 12, 2006
Try this:




<html><head>
<title>DaForm</title>
<script type="text/javascript">
function copyConditional(c,i1,i2) {
(c.checked)? i2.value=i1.value : i2.value='';
}
</script>
</head>
<body>
<form>
<table width="650" border="1" cellspacing="0" cellpadding="0">
<tr align="left" valign="top">
<td><p>Child</p>
<p>Email:  
<input name="email" type="text" id="email" value="me@me.com">
</p>
<p>Phone:
<input name="phone" type="text" id="phone" value="555-1212">
</p></td>
<td><p>Parent</p>
<p>(Click if info is the same
<input name="dateCopy" type="checkbox" onClick="
copyConditional(this,
this.form.email,
this.form.email2);
copyConditional(this,
this.form.phone,
this.form.phone2);
">
)<br>
<br>
Email:  
<input name="email2" type="text" id="email2">
</p>
<p>Phone:
<input name="phone2" type="text" id="phone2">
</p></td>
</tr>
<tr align="left" valign="top">
<td colspan="2"><input type="reset"></td>
</tr>
</table>
<br>
</form>
</body>
</html>

























"Julesmg" <webforumsuser@macromedia.com> wrote in message
news:e9342b$5h3$1@forums.macromedia.com...
> Hi ,
>
> I have a form to input a club members details including their address. The
> club member is a child and so there is a related parent/guardian address
> table.
> My question is, how do I get my form to autofill the parent /guardians
> address
> if it is the same as the childs address so that the record can be
> submitted to
> my database without having to fill in the address twice?
>
> I have seen forms with tick boxes to say the address is the same for
> delivery
> as for cerdit card holder for example. How is this done please? Any
> guidance
> appreciated.
>
> Thanks
>
> Jules
>
> I am using ASP with MS Access.
>


Translate
Correct answer
July 12, 2006
Hi Guys,

Thanks. Yes the Javascript route is the way for me. Thanks for your input. Appreciated. Jules
Translate