A simple jQuery script should be ok:
<script type="text/javascript" src="scripts/jquery-1.2.6.min.js"></script>
<script type="text/javascript">
$(function () {
$("select[name=numberOfPeople]").change(function() {
var numberOfPeopleChosen = $(this).val();
for (var i = 1; i <= 5; i++) {
var names = $("#names_" + i);
if (i <= numberOfPeopleChosen) {
names.show();
} else {
names.hide();
}
}
});
});
</script>
<style>
.hidden {
display: none;
}
</style>
<cfoutput>
<form>
How many people: <select name="numberOfPeople">
<option value="0">Choose</option>
<cfloop from="1" to="5" index="i">
<option value="#i#">#i#</option>
</cfloop>
</select>
<br />
<cfloop from="1" to="5" index="i">
<div class="hidden" id="names_#i#">
First name #i#: <input type="text"
name="firstName_#i#" />
Last name #i#: <input type="text"
name="lastName_#i#" />
</div>
</cfloop>
</form>
</cfoutput>
Not perfect and there are a bunch more ways to do this but it works nicely
and is fairly simple.
Adrian
> -----Original Message-----
> From: Les Mizzell [mailto:[email protected]]
> Sent: 18 January 2009 05:29
> To: cf-talk
> Subject: Re: Controlling the Number of Inputs with a Dropdown
>
> Ryan Stille wrote:
> > You can do this all with JavaScript, it works really slick. I just
> did this a few weeks ago and wrote a blog post about
> it:http://www.stillnetstudios.com/2009/01/05/dynamically-adding-and-
> removing-form-elements/
>
> That's pretty nice. I've not been able to get it to work so far though.
> Hmmm... Still playing with it.
>
> Haven't had any luck figuring out a Coldfusion/Ajax solution yet
> either.
>
> Once I figure it out - either way, I'll post the solution though. Still
> hacking away at it and looking for a good tutorial on an Ajax solution.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:318141
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4