/    Sign up×
Community /Pin to ProfileBookmark

I need to dynamically create new drop down and text boxes.

I’m selling photos online, so there could be 8-10 size options for each item. For neatness, I’d like the page to start with just the photo and a single drop-down and text box next to it. Something like this:

[CODE]

Size:
<select name=”select” class=”product-attr-size”>
<option price=”$1.00″>wallet</option>
<option price=”$2.00″>3×5</option>
<option price=”$3.00″>4×6</option>
<option price=”$4.00″>5×7</option>
<option price=”$5.00″>8×10</option>
<option price=”$6.00″>11×14</option>
</select>
Quantity:
<input name=”quantity” type=”text” value=”0″ size=”5″ maxlength=”3″ />

[/CODE]

Now if the user adds a quantity to the text box (greater than zero) will it display a new drop-down and text box. Follow the same check for each new box, and ideally only show the choices that are leftover from previous selections (no duplicate sizes down the list, or if they choose all sizes the last one wouldn’t make a new drop-down).

I’ve searched for something like this but I’ve been unable to find anything. Maybe I’m just using the wrong terminology. Any guidance would be greatly appreciated. Thanks.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangMay 26.2008 — Although this is doable using DOM cloneNode and then deleting options, it is user unfriendly.

The user has no way of changing the previous selection other than reloading the page.
Copy linkTweet thisAlerts:
@KorMay 26.2008 — Although this is doable using DOM cloneNode and then deleting options, it is user unfriendly.

The user has no way of changing the previous selection other than reloading the page.[/QUOTE]

Oh, but he can...The code can simple remove all the boxes below the last change. But, [B]erikbeam[/B], would not be simpler to use a single list box, a number (equal with the number of potions) of hidden inputs and a div to show the user what he has chosen so far, a sort of "basket"?
×

Success!

Help @erikbeam 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.18,
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,
)...