0

It's probably easiest to view this fiddle: http://jsfiddle.net/Ahfm7/4/

Only the agent and extension values in the dropdown have been implemented at this time.

I have encountered a couple of bugs I was hoping someone could help figure out.

  • The first is when you add a new row of dropdowns without selecting anything in the first and proceed to select an option in the second one, the form can be submitted.

  • Likewise if you pick an option in the first row, then add another and remove it, the submit button remains disabled.

I was just wondering if anyone knows how to fix this?

7
  • 3
    just being polite, don't need to be narky about it Commented Apr 26, 2011 at 13:43
  • These seem like simple issues if you wrote the js in the fiddle -- do you really not know how how to fix these two issues? Commented Apr 26, 2011 at 13:50
  • Is there any CSS associated with the disabled and advancedsubmit classes on the submit button? Otherwise, I don't see any point in adding/removing those classes. Also, it doesn't look like the extension option has been implemented. I only see agent. Commented Apr 26, 2011 at 13:54
  • I did write the js in the fiddle but I asked a lot of questions on the way. I think the answer will be relatively simple but I just don't know how to achieve it. I think I need to check if at least one of the tags dropdowns contains tag. Commented Apr 26, 2011 at 13:57
  • @Matt Ball, yes, there are some css classes relating to disabled and advancedsubmit but I am trying to keep the fiddle as light as I can. Commented Apr 26, 2011 at 13:58

2 Answers 2

1

I started cleaning up the code. I cut the 700+ lines of JS down to something more manageable for SO, but you should be able to understand the general idea.

http://jsfiddle.net/mattball/5ubTe/

In general:

  • Avoid re-querying the DOM by caching jQuery objects
  • Stay DRY by writing more, smaller functions which contain commonly reused logic (such as the enableSubmitButton function I added)
  • Don't forget to use var
Sign up to request clarification or add additional context in comments.

6 Comments

thanks, the jsfiddle site seems to be going slow at the moment so it might be that but the adding (and deleting) of dropdowns doesn't seem to work. Was the class to enable the submit button the only thing that you added? Also, why did you comment some lines out that are needed?
Yes, I took a break since jsFiddle was running unusably slow. I commented out lines like $(this).next("select[name='values'] option").remove(); because that same logic was already done by the earlier line: $operands.next("select.values").empty().
I see, but I don't see why those 2 lines are doing the same thing - very similar yes but those are removing any options that might be there for the 2nd and 3rd dropdowns whose values are populated by the selection of a value in the first list?
Made a bit of an improvement, I think the only case I need to sort is when at least 3 rows and for example, the second row has tag selected, the form can be submitted, also, if the third row is deleted, the form can still be submitted. Ah, just realised my fall back to enable submission when there is one row isn't foolproof since if that is set to tag then the form can still be submitted..... back to the drawing board I guess. A loop springs to mind in order to check if any have the tag value but can't think of how to do that right this minute... jsfiddle.net/5ubTe/12
I've tried the following but that doesn't work yet either: jsfiddle.net/5ubTe/14
|
0

I finally almost have a complete working solution but with one bug:

http://jsfiddle.net/5ubTe/72/

Thanks for your advice.

Comments

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.