Jump to content
php.lv forumi

OnChange event + PHP


euphoric

Recommended Posts

Labs vakars !

 

Lietas būtība :

 

http://site.lv/veikals/visas

 

<select size="1" name="pilsetas" onchange="???">
  <option value="Visas" selected="selected">Visas</option>
  <option value="Riga">Rīga</option>
  <option value="Ogre">Ogre</option>
  <option value="Aizkraukle">Aizkraukle</option>
</select>

 

Gribas pārmaiņas, -tikt vaļā no Submit'a .

 

1. Gribētos jau protams visu elementārāk :

Uz OnChange, pārmet: http://site.lv/veikals/value

 

Bet tā pa taisno izvilkt Value drošvien nevar ?

 

2. Tad vismaz uz OnChange izsukt PHP scriptu, kas savukārt ar $_POST ievāks Value un tad jau redirekts ?

 

Kādi varianti, domu gājiens pareizs ?

 

Pāldies ! :)

Link to comment
Share on other sites

Pirmais variants droši vien ir diezgan elementās. Uz onchange eventa redirekto uz adresi, kurai galā pielikta dropdownī izvēlētā vērtība. Cerams, ka tas ko gribēji

 

Javascript

function redirect(val) {
 window.location="http://site.lv/veikals/"+val;
}

 

HTML

<select size="1" name="pilsetas" onchange="redirect(this.options[this.selectedIndex].value)">
  <option value="Visas" selected="selected">Visas</option>
  <option value="Riga">Rīga</option>
  <option value="Ogre">Ogre</option>
  <option value="Aizkraukle">Aizkraukle</option>
</select>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...