1

I'll start with the code:

<input type="text" name="13939069" alt="2171">
<input type="text" name="2171">

Basically the name is the category ID, and when there is an alt value present, it is the id of the parent category.

What needs to happen is when the value of the parent category is changed the value of the child categories are also changed.

1321941
  • 2,139
  • 5
  • 26
  • 49
  • 1
    Side note: use [HTML5 `data-*` attributes](http://www.w3.org/TR/2010/WD-html5-20100624/elements.html#embedding-custom-non-visible-data) for custom data storage. – James Allardice Jun 07 '12 at 10:33

1 Answers1

2

here's a fiddle i've made for your simple case: http://jsfiddle.net/shershen08/qhCUr/3/

shershen
  • 9,875
  • 11
  • 39
  • 60
  • Thank you, but it would need to be dynamic, how would that work? – 1321941 Jun 07 '12 at 10:52
  • dynamic what? be more concrete pls – shershen Jun 07 '12 at 11:01
  • As in there will be lots of fields with different names and alt attributes, and it would need to be able to work for all of them. – 1321941 Jun 07 '12 at 11:04
  • Thank you!! one last question would the js go about or below the fields? – 1321941 Jun 07 '12 at 11:34
  • didn't get you from first time again ))). key idea is to group all parent fileds by class ".parentFld" and all childs fields by class ".chFiled", and connection btwn them is a data-papa attribute as @James Allardice wrote – shershen Jun 07 '12 at 11:40
  • *sorry there was a typo: Basically would I put the javascript above or below the form? – 1321941 Jun 07 '12 at 11:41
  • If that link ever goes bad, your answer will be rendered useless for future readers. Please add the relevant code to the answer itself. Cheers! – domsson Jan 18 '20 at 13:27