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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A simple question 1

Status
Not open for further replies.

echostorm

Vendor
Apr 10, 2005
28
AU
Hey all,

I am desperate. All I need is a variable like function...

Basically the result received from this "chained select" below (result located at the final FINAL RESULT arrow on the code below) to go into the nominated field (the one with final result goes here marked on it) on the form below it. Please help.

(CHAINED SELECT)
addListGroup("choices", "category");

addOption("category", "Select a category", "");
addList("category", "choice1", "", "choice1");
addList("category", "chioce2", "", "choice2");

addOption("choice1", "Select a sub catagory", "");
addOption("choice1", "subcata", "subcata");
addOption("choice1", "subcatb", "subcatb");
addOption("choice1", "subcatc", "subcatc");

addOption("choice2", "Select a sub catagory", "");
addOption("choice2", "subcat1", "subcat1");
addOption("choice2", "subcat2", "subcat2");
addOption("choice2", "subcat3", "subcat3"); <---- FINAL RESULT



(FORM)
<FORM NAME=order ACTION="managecart.html" onSubmit="AddToCart(this);">
Quantity: <input type=text size=2 maxlength=3 name=QUANTITY onChange='this.value=CKquantity(this.value)' value="1">
<input type="image" src="./images/select.gif" border=0 value="Add to Cart" align=top>
<input type=hidden name=PRICE value=" ***********FINAL RESULT APPEAR HEAR************** ">
</FORM>

Any Ideas

Echo

 

You need to put an onchange attribute in your select element code, something like this:

Code:
<select onchange="updateField(this);">

and then have a JavaScript function to assign the value desired to the form field, something like this:

Code:
function updateField(selObj) {
   if (selObj.selectedIndex != -1) {
      document.forms['order'].elements['PRICE'].value = selObj.options[selObj.selectedIndex].value;
   }
}

Of course, the actual code required may differ. You've not given details of:

1. The select element,
2. Whether you want the text or the value of the selected option entered into the field (you say simply "the result", which is meaningless in code terms).

Incidentally, you might also want to check the spelling throughout your entire site, as you seem to change the spelling of the word "category" from place to place.

Hope this helps,
Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
Thanks Billy,

I posted this problem on other forums and noone new what the heck I was talking about.

Here is an example of my challenge...

I need the result of this drop down menu

to fill in a variable field on this button

the .js files for the two files can be found here

Cheers. :)

Echo
 
Problem is still there. I cant figure this out :( I have spent 2 days on one tiny little problem. One task that would be simple for a javascript programmer. I am not so I am completly lost. PLEASE HELP
 

So you want to change the action of a button in another page? That differs greatly from "to go into the nominated field on the form below it". Perhaps one of the reasons that people on other forums didn't know what you wanted is because you didn't explain it clearly?

How does the second page relate to the first? Is it a form submission page? A popup? How is it called?

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
It is meant to be on the same page. I have it on 2 pages to make it simple to read. hmm looks like I did the opposite.
 
Is it possible to have the generated and interpreted form on the same page? i.e. combining add.html with chained.html. so they are on the same.html page?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top