Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #16409
| From | JJ <jaejunks_at@_googlemail_dot._com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: How do we carry re-assignment element value? |
| Date | 2012-10-05 00:41 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <XnsA0E34ED072FE2jaejunksgooglemailco@0.0.0.44> (permalink) |
| References | <35097a25-2320-4fd0-ac26-bb2e2d310439@x14g2000yqh.googlegroups.com> |
justaguy <lichunshen84@gmail.com> wrote:
> When the form is submitted several times before its final submission.
You lost me there. Once a form is submitted, it's final. A form can't be
partially submitted.
> The idea of having the TEXT input field with id of "addNew" is to
> alllow user to add another value other than from the drop-down list.
>
> js code:
> var selObj = document.getElementById('delivery');
> el = document.getElementById('addNew');
> selObj.options[selObj.selectedIndex].value = el.value;
>
> The code works. However, this FORM is sent several times based on
> certain cell selection before Final Submission, what is happening now
> is on subsequent form submission (prior to Final Submission) we lose
> its re-assignment, namely,
> selObj.options[selObj.selectedIndex].value = el.value;
> How do we circumvent this problem?
That code replace the item value that's currently being selected, instead
of adding a new one. To add a new item selection (new OPTION tag), use
this:
//create new OPTION element
var el = document.createElement('OPTION');
//set the value
el.value = document.getElementById('addNew').value.trim();
//set the display text (for display only; optional)
el.textContent = document.getElementById('addNew').value.trim();
//append the new OPTION element into "delivery" selector
document.getElementById('delivery').appendChild(el);
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How do we carry re-assignment element value? justaguy <lichunshen84@gmail.com> - 2012-10-04 12:46 -0700
Re: How do we carry re-assignment element value? Danny <dann90038@gmail.com> - 2012-10-04 15:57 -0700
Re: How do we carry re-assignment element value? JJ <jaejunks_at@_googlemail_dot._com> - 2012-10-05 00:41 +0000
Re: How do we carry re-assignment element value? justaguy <lichunshen84@gmail.com> - 2012-10-04 19:09 -0700
csiph-web