Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [HTML]Link formularza GET
motorolka24
post
Post #1





Grupa: Zarejestrowani
Postów: 90
Pomógł: 0
Dołączył: 21.04.2007

Ostrzeżenie: (0%)
-----


Witam. Jak z poniższego formularza po kliknięciu na szukaj można uzyskać po wpisaniu np. "abc abc2 abc3" link "?tekst=abc+abc2+abc3" zamiast "?tekst=abc abc2 abc3"?

  1. <form action='szukaj' method='get'>
  2. <input type='text' name='tekst' value=''/>
  3. <input type='submit' value='szukaj'/>
  4. </form>
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 7)
Otto
post
Post #2





Grupa: Zarejestrowani
Postów: 144
Pomógł: 7
Dołączył: 22.03.2010

Ostrzeżenie: (0%)
-----


  1. str_replace(" ", "+", $_GET['tekst'])
Go to the top of the page
+Quote Post
motorolka24
post
Post #3





Grupa: Zarejestrowani
Postów: 90
Pomógł: 0
Dołączył: 21.04.2007

Ostrzeżenie: (0%)
-----


no ale to co napisałeś to mogę zrobić po przeładowaniu strony i wtedy i tak mam adres ?tekst=abc abc2 abc3"
Go to the top of the page
+Quote Post
ciekawskiii
post
Post #4





Grupa: Zarejestrowani
Postów: 467
Pomógł: 39
Dołączył: 7.11.2010
Skąd: Raz tu, raz tam

Ostrzeżenie: (30%)
XX---


Dobrze Ci podal bo dziala a jak Ty chcialbys takim formularzem uzyskac efekt bez przeladowania?


--------------------
Go to the top of the page
+Quote Post
Hoku
post
Post #5





Grupa: Zarejestrowani
Postów: 49
Pomógł: 2
Dołączył: 6.07.2010

Ostrzeżenie: (0%)
-----




  1. <form action='szukaj' method='get' onsubmnit="document.getElementById('tekst').value=document.getElementById('tekst').value.replace(' ', '+');">
  2. <input type='text' id='tekst' name='tekst' value=''/>
  3. <input type='submit' value='szukaj'/>
  4. </form>


o takie coś chodziło?
Go to the top of the page
+Quote Post
flashdev
post
Post #6





Grupa: Zarejestrowani
Postów: 812
Pomógł: 117
Dołączył: 2.12.2008

Ostrzeżenie: (10%)
X----


Cytat(Hoku @ 10.01.2011, 00:23:22 ) *
  1. <form action='szukaj' method='get' onsubmnit="document.getElementById('tekst').value=document.getElementById('tekst').value.replace(' ', '+');">
  2. <input type='text' id='tekst' name='tekst' value=''/>
  3. <input type='submit' value='szukaj'/>
  4. </form>


o takie coś chodziło?


+ mała poprawka:
Kod
...replace(/\s/g, '-')


+ sugestia:
I nie onsubmit, tylko addeventlistener.


--------------------
Go to the top of the page
+Quote Post
Hoku
post
Post #7





Grupa: Zarejestrowani
Postów: 49
Pomógł: 2
Dołączył: 6.07.2010

Ostrzeżenie: (0%)
-----


onsubmit to najprostszy przykład zapomniałeś wspomnieć, że ie nie wspiera standardu addeventlistener tylko ma swojego attachevent
Go to the top of the page
+Quote Post
flashdev
post
Post #8





Grupa: Zarejestrowani
Postów: 812
Pomógł: 117
Dołączył: 2.12.2008

Ostrzeżenie: (10%)
X----


Cytat(Hoku @ 10.01.2011, 01:07:08 ) *
onsubmit to najprostszy przykład zapomniałeś wspomnieć, że ie nie wspiera standardu addeventlistener tylko ma swojego attachevent


Racja, chociaż nie zapomniałem, a chciałem tylko nakierować na dobrą drogę.

Kod
    function addEvent(obj, evType, fn){
        if (obj.addEventListener){
            obj.addEventListener(evType, fn, false);
            return true;
        }else if (obj.attachEvent){
            var r = obj.attachEvent('on'+evType, fn);
            return r;
        }else{
            return false;
        }
    }


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 22:04