/    Sign up×
Community /Pin to ProfileBookmark

Checkboxes in Forms

Hello:

I was wondering if someone can help me out.

I’ve created a form which contains three sets of checkboxes. The first checkbox is behavior[]. The second is current[]. The third is prior[].

The behavior[] is the root element. The values that go into behavior[] are: Abuse, Agression, Eating Disorder, etc.

The current[] is a child element to behavior[]. The values for current[] are Physical, Mental, Verbal, etc.

The prior[] is a child element to behavior[] as well. The values are the same as in current[].

Therefore the result after submitting my form should show something like this:
Behavior:Current
Abuse?hysical
Abuse:Mental
Agression:Younger Child
Agression:Adult

Does anyone know how to code the form so I can have the relationship between behavior[] and current[] as well as behavior[] and prior[]?

This is how my form looks so far. I only included one behavior and its current and prior options. There are over 50 behaviors.

[CODE]
<table class=”apptable”>
<tr><th scope=”col”>Behavior</th><th scope=”col”>Current</th><th scope=”col”>Past</th></tr>
<tr><td class=”i”>
<input type=”checkbox” name=”behavior1[]” value=”Abuse”<?php echo ( isset ( $_SESSION[‘behavior1’] ) && in_array(‘Abuse’, $_SESSION[‘behavior1’]) ? ‘ checked=”checked”‘ : ” ); ?> />Abuse&nbsp;&nbsp;</td>
<td class=”h”>
<input type=checkbox name=current1[] value=”Physical”<?php echo ( isset ( $_SESSION[‘current1’] ) && in_array(‘Physical’, $_SESSION[‘current1’]) ? ‘ checked=”checked”‘ : ” ); ?> />Physical&nbsp;&nbsp;
<input type=checkbox name=current1[] value=”Emotional”<?php echo ( isset ( $_SESSION[‘current1’] ) && in_array(‘Emotional’, $_SESSION[‘current1’]) ? ‘ checked=”checked”‘ : ” ); ?> />Emotional<br>
<input type=checkbox name=current1[] value=”Sexual”<?php echo ( isset ( $_SESSION[‘current’] ) && in_array(‘Sexual’, $_SESSION[‘current1’]) ? ‘ checked=”checked”‘ : ” ); ?> />Sexual&nbsp;&nbsp;&nbsp;&nbsp;
<input type=checkbox name=current1[] value=”Recent”<?php echo ( isset ( $_SESSION[‘current1’] ) && in_array(‘Recent’, $_SESSION[‘current1’]) ? ‘ checked=”checked”‘ : ” ); ?> />Recent<br></td>
<td class=”h”>
<input type=checkbox name=prior1[] value=”Physical”<?php echo ( isset ( $_SESSION[‘prior1’] ) && in_array(‘Physical’, $_SESSION[‘prior1’]) ? ‘ checked=”checked”‘ : ” ); ?> />Physical&nbsp;&nbsp;
<input type=checkbox name=prior1[] value=”Emotional”<?php echo ( isset ( $_SESSION[‘prior1’] ) && in_array(‘Emotional’, $_SESSION[‘prior1’]) ? ‘ checked=”checked”‘ : ” ); ?> />Emotional<br>
<input type=checkbox name=prior1[] value=”Sexual”<?php echo ( isset ( $_SESSION[‘prior1’] ) && in_array(‘Sexual’, $_SESSION[‘prior1’]) ? ‘ checked=”checked”‘ : ” ); ?> />Sexual&nbsp;&nbsp;&nbsp;&nbsp;
<input type=checkbox name=prior1[] value=”Recent”<?php echo ( isset ( $_SESSION[‘prior1’] ) && in_array(‘Recent’, $_SESSION[‘prior1’]) ? ‘ checked=”checked”‘ : ” ); ?> />Recent<br></td>
</tr> </table>
<input type=”submit” name=”btnSubmit” id=”btnSubmit” value=”Update Record” class=”btn” >
<input type=”hidden” name=”submitted” value=”TRUE” />

</form>
[/CODE]

Thanks for the help.

to post a comment
HTML

1 Comments(s)

Copy linkTweet thisAlerts:
@ray326Aug 05.2007 — That really sounds more like a PHP question; like how it handles the mapping of the form input names.
×

Success!

Help @focus310 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...