3 maj 2008

Odczyt text pola Select i wstawienie do pola input

Parametry: formaularz, pole select, pole input

function ustawNazwePozycji(form, fld, name) {
  idx = fld.selectedIndex;
  text = fld.options[idx].text;
  fld_name = form.elements[name];
  fld_name.value = text;
}
5 kwi 2008

Generowanie losowej nazwy obrazka

rnd = Math.ceil(Math.random()*131) + 10000
obrazek_anim = '' + rnd
obrazek_anim = '<img src="anim/'+obrazek_anim.substr(1,4)+'.gif">'
5 kwi 2008

Wycięcie z url nazwy obrazka

// index.html ? img = 9220_007.jpg

function f(param) {
  adres = param.href + ""
  ib = adres.length
  ia = ib - 12
  obrazek = adres.substring(ia, ib)
  window.location = "index.html?img=" + obrazek
}