By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,462 Members | 1,057 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,462 IT Pros & Developers. It's quick & easy.

how to dynamically change form elements?

P: n/a
hi, all, thanks for reading.

i have a form in which i want drop down boxes to dynamically change some
hidden fields:
http://cynthialoganjewelry.com/test4.htm

<form name=test method="post" >

Pearl Color:
<select name="product1[]">
<option value="Pearl: White" selected>White</option>
<option value="Pearl: Lavendar">Lavendar</option>
<option value="Pearl: Blue">Blue</option>
</select>

Crystal Color :
<select name="product1[]">
<option value="Crystal: White Opal" selected>White Opal</option>
<option value="Crystal: Crystal AB">Crystal AB</option>
<option value="Crystal: Black Diamond">Black Diamond</option>
</select>

Cap Choices:
<select name="product1[]">
<option value="Cap: Plain" selected>Plain</option>
<option value="Cap: Fancy">Fancy</option>
<option value="Cap: Regal">Regal</option>
</select>

<INPUT TYPE="HIDDEN" NAME="product2[]" VALUE="GET VALUES FROM ABOVE">
<INPUT TYPE="HIDDEN" NAME="product3[]" VALUE="GET VALUES FROM ABOVE">

<input name="submit" type="submit">
</form>

in the value of the hidden fields, i want a concatenation of the three
select elements(the option value, not the text) above, like:
Pearl: White Crystal: White Opal Cap: Fancy

and it needs to post as if those selected options were hard coded into the
hidden fields.

ps, the <select name="product1[]"> cannot change

thanks for your time, i'm all out of google<G>
--

juglesh B>{)}

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"juglesh" <ju*****@nospamRadioKDUGspamsux.com> wrote in message
news:KpSoc.43624$iF6.4061654@attbi_s02...
hi, all, thanks for reading.

i have a form in which i want drop down boxes to dynamically change some
hidden fields:
http://cynthialoganjewelry.com/test4.htm

<form name=test method="post" >

Pearl Color:
<select name="product1[]">
<option value="Pearl: White" selected>White</option>
<option value="Pearl: Lavendar">Lavendar</option>
<option value="Pearl: Blue">Blue</option>
</select>

Crystal Color :
<select name="product1[]">
<option value="Crystal: White Opal" selected>White Opal</option>
<option value="Crystal: Crystal AB">Crystal AB</option>
<option value="Crystal: Black Diamond">Black Diamond</option>
</select>

Cap Choices:
<select name="product1[]">
<option value="Cap: Plain" selected>Plain</option>
<option value="Cap: Fancy">Fancy</option>
<option value="Cap: Regal">Regal</option>
</select>

<INPUT TYPE="HIDDEN" NAME="product2[]" VALUE="GET VALUES FROM ABOVE">
<INPUT TYPE="HIDDEN" NAME="product3[]" VALUE="GET VALUES FROM ABOVE">

<input name="submit" type="submit">
</form>

in the value of the hidden fields, i want a concatenation of the three
select elements(the option value, not the text) above, like:
Pearl: White Crystal: White Opal Cap: Fancy

and it needs to post as if those selected options were hard coded into the
hidden fields.

ps, the <select name="product1[]"> cannot change

thanks for your time, i'm all out of google<G>
--

juglesh B>{)}


I think you are looking for something like the following:

function updatefield()
{
lsel1 = document.forms["test"]["selPearl"].value
lsel2 = document.forms["test"]["selCap"].value
document.forms["test"]["product1"].value = lsel1 + lsel2
}

NOTE: I would name each element accordingly

<form name=test method="post" >
<select name="selPearl" onchange="updatefield();">
<option value="Pearl: White" selected>White</option>
<option value="Pearl: Lavendar">Lavendar</option>
<option value="Pearl: Blue">Blue</option>
</select>
<select name="selCap" onchange="updatefield();">
<option value="Cap: Plain" selected>Plain</option>
<option value="Cap: Fancy">Fancy</option>
<option value="Cap: Regal">Regal</option>
</select>
<INPUT TYPE="HIDDEN" NAME="product1" VALUE="">
</form>

I left out the third select...I'm sure you can get it from here.

HTH
-Bruce Duncan
Jul 23 '05 #2

P: n/a
Bruce Duncan wrote:
"juglesh" <ju*****@nospamRadioKDUGspamsux.com> wrote in message
news:KpSoc.43624$iF6.4061654@attbi_s02...
hi, all, thanks for reading.

i have a form in which i want drop down boxes to dynamically change
some hidden fields:
http://cynthialoganjewelry.com/test4.htm
and it needs to post as if those selected options were hard coded
into the hidden fields.

ps, the <select name="product1[]"> cannot change


I think you are looking for something like the following:

function updatefield()
{
lsel1 = document.forms["test"]["selPearl"].value
lsel2 = document.forms["test"]["selCap"].value
document.forms["test"]["product1"].value = lsel1 + lsel2
}

NOTE: I would name each element accordingly
well, thats the thing, the hidden element has to have the names i gave them
to post to the cart properly. also, there are a few elements in the form
with the same name="product1[]" , which completely broke it for some reason,
i would think it would have changed the value in either just the first
product1[]" it came to or to all of them.

so, instead i used
document.forms["choices"].elements[1].value = lsel1 + lsel2

to insert the value into a hidden field in a completely different form from
the color choices. set the variables with the first form, actually submit
the second.

thanks alot, a shove in the right direction is usually all i need!
appreciate it.

<form name=test method="post" >
<select name="selPearl" onchange="updatefield();">
<option value="Pearl: White" selected>White</option>
<option value="Pearl: Lavendar">Lavendar</option>
<option value="Pearl: Blue">Blue</option>
</select>


--

juglesh B>{)}
www.RadioKDUG.com


Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.