0

I'm building shopping mall website using Yahoo solution. My products have multiple options which are dependent on previous options. The problem is that in Yahoo, I have to locate options in the order form to appear in checkout page. Nested form doesn't work, of course. Here is one sample page: http://parseven.com/sample-1.html Can anybody help me please?

2
  • Where do you want to submit the form to, Yahoo! or your site? Remove the form tag for the one you don't want and be done with it. Commented Jan 30, 2010 at 0:23
  • I want to submit the form to Yahoo, since Yahoo is the solution.If I remove the form tag, what do I have to replace it? I'm novice to js. Any help will be appreciated. Commented Jan 30, 2010 at 1:33

1 Answer 1

2

Your question is not very clear, but if I understand you correctly what you need is instead of using document.formname.subcategory.options[0] use document.getElementsByName("subcategory")[0].options[0].
document.getElementsByName("subcategory") will return you an array of all element on the page with the name="subcategory", from there you select the first one [0]. After that you can access all of its options.
I would suggest giving your dropdown an id instead of the name. Then you can use document.getElementById("unique-dropdown-id") and that will return you a reference to the select element, instead of array.

Adding more information based on new comments:
In order to make your new example (http://parseven.com/java_ex.html) work without form, remove opening and closing form tags from the page all together. Search for "document.formname.subcategory" and replace it with "document.getElementsByName("subcategory")[0]" and everything will work exactly the same way is it works now.
Since you need to submit your information to Yahoo, you have to keep form tag around, but you can't nest one form tag inside the other. Just leave the Yahoo's form tag intact and remove you other form tag.

Sign up to request clarification or add additional context in comments.

12 Comments

getElementsByName isn't necessary.
My previous comment looks gruffer than I intended. document.forms[0].subcategory.options works as well as getElementById would.
I want to change JS in the html. parseven.com/java_ex.html Could you show me how to get rid of form and still working?
In the yahoo solution, I have to locate the options inside "order form". Otherwise, the options don't show up in the checkout pages. The problem is that this js options are form, and form can not be inside form.Is it clear now?
Thanks a lot, Ilya! You are the best! It works perfect, but I need a little more help. How can I expand more options parseven.com/java_ex.htm? Now I have two drop down options there and I want to have three more. Could you help me? Thanks in advance!
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.