0

I have a primary drop down list that has three values: 1 - select 2 - Fail 3 - pass

the page is populated from the database, so here you could have anything from 1 to 50 dropdown to set the status of each record as fail or pass.

I would like to select 'fail' from the primary dropdown, any dropdown's that are populated from database should set to the selection i have made as being 'fail'

hope someone can help. thank you Yas

Yasir H
  • 3
  • 3

1 Answers1

0

You can do this using javascript or jquery.

OnChange of first dropdown, select all dropdown values accordingly.

EDIT:

For your reference, I have prepared an example. Refer LIVE DEMO

HTML:

<select class="dDown">
    <option value="select">select</option>
    <option value="Pass">Pass</option>
    <option value="Fail">Fail</option>
</select>
<select>
    <option value="select">select</option>
    <option value="Pass">Pass</option>
    <option value="Fail">Fail</option>
</select>
<select>
    <option value="select">select</option>
    <option value="Pass">Pass</option>
    <option value="Fail">Fail</option>
</select>
​

JS:

$('.dDown').on("change", function() {
    $('select').not('.dDown').val(this.value);
});​
Siva Charan
  • 17,940
  • 9
  • 60
  • 95
  • I'm using ajax with javascript, the code i've worked on in javascript, will only select the first one, but if there are more than one then nothing happens – Yasir H Aug 06 '12 at 16:26
  • @YasirH: For your reference, I have prepared a sample example. Check my updated answer. – Siva Charan Aug 06 '12 at 16:29
  • thank you very much, this reference with the live demo is much appreciated. I've tried that, but could'nt get it to work, as my code is using ajax, i will send you an example of what i'm doing. – Yasir H Aug 06 '12 at 16:39
  • @YasirH: yeah, that would be great. – Siva Charan Aug 06 '12 at 16:42
  • I cant seem to add my code, its not allowing me to add it as a comment – Yasir H Aug 06 '12 at 16:48
  • – Yasir H Aug 06 '12 at 16:49
  • <% if not rs4.eof and not rs4.bof then %> <% while not rs4.eof and not rs4.bof %> <% rs4.movenext wend %> <% end if %> function setDropDown(){ $('.dDown').on("change", function() { $('select').not('.dDown').val(this.value); }); } – Yasir H Aug 06 '12 at 16:50
  • @YasirH: Remove `onchange="setDropDown"` on all option tags. You should include jquery js file on the page then use this jquery code `$('.dDown').on("change", function() { $('select').not('.dDown').val(this.value); });` – Siva Charan Aug 06 '12 at 17:17
  • Hi Siva, I'm not that familiar with jquery, i did include the jquery file to the file i'm working on and removed the onclick, but i'm getting an error ('mso.style' is null or not an object) – Yasir H Aug 07 '12 at 08:47
  • hi again, i'm having problems with this as jquery will not work due to the way the system has been built. could someone help so that this code works on javascript – Yasir H Aug 07 '12 at 09:51