473,385 Members | 1,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how to dynamically change form elements?

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
2 12855
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: LRW | last post by:
I have no idea if this is more a PHP question or Javascript question, because my problem hinges equally on both. I have a PHP script that queries a database and creates a list of rows for each...
4
by: Terry | last post by:
I have a number of input boxes used to display totals based on selected items for each row in a table. There are more than a few rows that are identical, except for the form field name. I have...
1
by: Will | last post by:
Hi, I have a problem trying to validate dynamically created html form elements using javascript. I have dynamically created a check box using ASP for each record in a recordset and have given each...
1
by: CS Wong | last post by:
Hi, I have a page form where form elements are created dynamically using Javascript instead of programatically at the code-behind level. I have problems accessing the dynamically-created...
6
by: fidodido | last post by:
I was asked to do this.... Dynamically move "text1" and "hidden1" into the "form1" ..... Not by creating new elements, but moving the "text1" and "hidden1" elements into the form using javascript,...
4
by: Stone Chen | last post by:
Hello, I have form that uses javascript createElement to add additional input fields to it. However, my validating script will not process new input fields because it can only find the named...
5
by: stellstarin | last post by:
I have a html where fields are created and added dynamically on the client side. I use the AppendChild() call to create fields dynamically. On submit i try to get the value for all the...
1
by: adamredwards | last post by:
I have a page with some form elements that are dynamically generated. They are inserted into the dom by first cloning a node, changing the values like name, and then inserted with insertBefore(). ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.