Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

x = "document.forms.[0]."+id+"_4x6_cnt.value" ???

Status
Not open for further replies.

budapestnori

Technical User
Jan 15, 2004
33
HU
Ok, I understand this is passing a string, but what I want is to accept a parameter in the function call that is an id here it is "id" and then assign the value of that form element to a variable...not in the form of a string...
 
Perhaps you could take some time to rewrite your question so we will be able to help you.

Take the time to think your problem through, and describe it in a way that those of us not familiar with your specific problem and set-up will be able to help. Include any "extra" information that may be important as well.

Jeff
 
do you mean you want to access the form element?

like this:

Code:
document.forms[0].elements[id+"_4x6_cnt"].value = "Bob"
 
Now we have confused him!!!

My code will update the form element, new value "Bob", Dan's code will assign the form elements value to a variable (x)

And Jeff was right, it isn't very clear what you are after.

Simon
 
I'm sorry guys, if you look at this page - I think you can tell. Each image has a series of dropdowns associated with it. As each dropdown is changed, I want the total cost for that image to be computed. What I was thinking was that for each image, I would have an onchange function that would * the values of each dropdown against a given value, such as .29 for 4x6's, 1.99 for 8x10's, etc. Thus in my script, I would have six variables (in this scenario) and after multiplying each against a price, would add them together to give me a total for that image. If you look at it will be much clearer what I am attempting. Thanks so much. I am not sure if there is a better way to do it, but seeing as I am an amateur...
 
Extremely interesting, this dilema of mine. Ok, I got it to work, as the error I was making was not of referencing the form element by its corresponding number in the forms array, but by the name of the form dropdown object instead. This works, but what I need is a way to access ALL the form array elements whose name begins with the ID of a particular record. As in -

<select name="<%=rs("id")%>_4x6_cnt" onChange="calculatePrintTotal(<%=rs("id")%>)">

<select name="<%=rs("id")%>_5x7_cnt" onChange="calculatePrintTotal(<%=rs("id")%>)">

<select name="<%=rs("id")%>_8x10_cnt" onChange="calculatePrintTotal(<%=rs("id")%>)">

<select name="<%=rs("id")%>_20x30_cnt" onChange="calculatePrintTotal(<%=rs("id")%>)">
 
Here is yet more comments on this, but with a different possible approach (which is not working btw, but it further explains what I am after...)

I have a form (see I dynamically list a series of images, from which a person can choose various qtys. of prints. For example, 3 5x7's, 2 8x10's, etc. Each time a quantity of prints is changed, I want to keep a running sum total for that image. So far, I have created a loop which displays each image, adjacent to dropdowns for each dimension of that image that can be ordered. Each dropdown ( ie., <select>) if given a unique name, such as name="<%=rs("id")%>_5x7_qty", so as you can see for each image, I would have 6 unique <select> form elements all pertaining to that one given image. Anytime one of the qty's is altered, I need to get generate a new total for that particular image and display. I think the above url clearly will show what I'm after. You might also peek at as I have attempted in two different ways...
Thanks if you can help.
 
As a side note, I have been using a <select> statement and from I have read, it in itself does not have a value associated with it, rather its <options> array does...This might figure into my dilema
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top