Dynamically adding code in Dreamweaver CS4
Hi everyone,
I have the code below (see bottom of post) inside a form within Dreamweaver CS4. There's a dropdown menu where people can select the number of guests that will be attending an event, then beneath this are two text fields - one for firstname and the other for lastname - where they enter the name of the guest attending. Since they can choose from up to 15 from the guest dropdown menu indicating the amount of guests attending, I'd need there to be 14 more blocks of code like this:
<p>
<label for="guestFirstName">Firstname:</label>
<input type="text" name="guestFirstName" id="guestFirstName" tabindex="50" />
<label for="guestLastName">Last Name</label>
<input type="text" name="guestLastName" id="guestLastName" />
<br />
</p>
...that would allow them to enter further names for their guests if a higher number was chosen from the dropdown menu.
Is there a way either in Dreamweaver directly (or with one of the WA add-ons) to have added text fields inserted automatically based on the number of guests chosen in the dropdown? So say for example, if someone chose 5 guests, then a further 4 blocks of the above code would get inserted automatically?
Is this possible to do and if yes can someone explain how I'd go about it?
Or as an alternative, would there be a way to have a button for them to click so that more text fields are added as they need them, ie. if they chose 5 guests, then they'd click the button 5 times to add more text fields.
Thanks for any advice.
<fieldset>
<legend>Additional Guests</legend>
<p>Will you require ticketing for extra guests?<br />
<label>
<input type="radio" name="extraGuests" value="Yes" id="extraGuests_0" tabindex="20" />
Yes</label>
<br />
<label>
<input type="radio" name="extraGuests" value="No" id="extraGuests_1" tabindex="30" />
No</label>
</p>
<p>If yes, please provide the following details:<br />
<label for="OrderNumGuests">Number of Guests:</label>
<select name="OrderNumGuests2" id="OrderNumGuests" tabindex="40">
<option value="" selected="selected">-- Select a number --</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
</select>
<br />
</p>
<p>Name of Guest(s):</p>
<p>
<label for="guestFirstName">Firstname:</label>
<input type="text" name="guestFirstName" id="guestFirstName" tabindex="50" />
<label for="guestLastName">Last Name</label>
<input type="text" name="guestLastName" id="guestLastName" />
<br />
</p>
</fieldset>