Toon posts:

[SS] SelectedIndex

Pagina: 1
Acties:

Verwijderd

Topicstarter
Dmv volgende code
code:
1
document.lesson_form.dance_list.selectedIndex = dansCode;

kan ik een item uit een lijst 'selected' maken, op bases van de index.
Is er ook manier om dit te doen op basis van de value?

bv
code:
1
2
3
4
5
6
7
8
9
10
11
<select name="dance_list">
  <option value="1">Tango
  <option value="9">Foxtrot
  <option value="16">Quick step
  <option value="17">Weense Wals
  <option value="18">ChaChaCha
  <option value="19">Jive
  <option value="20">PasoDoble
  <option value="21">Rumba
  <option value="22">Samba
</select>

Als dmv van de ID wil werken lukt dit niet, want bij Foxtrot bijvoorbeeld geef ik dan als selectedindex 9, maar dan gaat hij naar Samba.

  • BtM909
  • Registratie: Juni 2000
  • Niet online

BtM909

Watch out Guys...

Op vrijdag 01 februari 2002 08:34 schreef sig__n het volgende:
Dmv volgende code
code:
1
2
3
4
5
6
7
8
9
10
11
<select name="dance_list">
  <option value="1">Tango
  <option value="9">Foxtrot
  <option value="16">Quick step
  <option value="17">Weense Wals
  <option value="18">ChaChaCha
  <option value="19">Jive
  <option value="20">PasoDoble
  <option value="21">Rumba
  <option value="22">Samba
</select>
code:
1
2
3
4
5
6
7
8
9
 dance_list_var = 5 //bijvoorbeeld

 for (var i = 0; i < dance_list.length; i++)
 {
  if (dance_list_var.value==dance_list[i].value)
  {
   dance_list.options[i].selected=true;
  }
 }

Ace of Base vs Charli XCX - All That She Boom Claps (RMT) | Clean Bandit vs Galantis - I'd Rather Be You (RMT)
You've moved up on my notch-list. You have 1 notch
I have a black belt in Kung Flu.


Verwijderd

Topicstarter
Op vrijdag 01 februari 2002 08:47 schreef BtM909 het volgende:

[..]
code:
1
2
3
4
5
6
7
8
9
 dance_list_var = 5 //bijvoorbeeld

 for (var i = 0; i < dance_list.length; i++)
 {
  if (dance_list_var.value==dance_list[i].value)
  {
   dance_list.options[i].selected=true;
  }
 }

Tnx, het werkt