Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Pobieranie danych z 2 pol tekstowych i wrzucenie, tych danych do kolejnego pola tekstowego
miedzna
post
Post #1





Grupa: Zarejestrowani
Postów: 401
Pomógł: 1
Dołączył: 10.03.2004
Skąd: Warszawa

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


Witam,
nie wiem, czy jest to wykonalne w JS, ale chodzi o to, że mam 3 pola tekstowego
  1. <INPUT TYPE="text" NAME="imie">
  2. <INPUT TYPE="text" NAME="nazwisko">
  3. <INPUT TYPE="text" NAME="email">

user wpisuje w 1 imię, w 2 nazwisko i kiedy przechodzi do 3 pola tekstowego, to w tym trzecim polu wskakują dane z dwóch poprzednich pól w postaci:
imie.nazwisko

User oczywiście może wykasować zawartość 3 pola, albo zmienić ją, natomiast chodzi o ułatwienie wpisywania smile.gif

To mi się wydaje nie jest wykonalne, bo w międzyczasie user nie klika w żaden button sad.gif

Dzięki za pomoc i pozdrawiam

Ten post edytował miedzna 17.11.2005, 11:21:14
Go to the top of the page
+Quote Post
mike
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 7 494
Pomógł: 302
Dołączył: 31.03.2004

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


Na przykład tak można:
  1. function dodaj()
  2. {
  3. var a = document.getElementById( 'surname' );
  4. var b = document.getElementById( 'name' );
  5.  
  6. document.getElementById( 'suma' ).value = a.value + '.' + b.value;
  7. }
  8.  
  9. <form action="#">
  10. <input id="surname" type="text" />
  11. <input id="name" type="text" />
  12. <br />
  13. <input id="suma" type="text" onfocus="dodaj();" />
  14. </form>
Go to the top of the page
+Quote Post
miedzna
post
Post #3





Grupa: Zarejestrowani
Postów: 401
Pomógł: 1
Dołączył: 10.03.2004
Skąd: Warszawa

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


Mocny jesteś smile.gif)) o to własnie mi chodziło, a czy da się usunąć ze zmiennej "suma" polskie litery i zamienić je na nie-polskie odpowiedniki? Bo w mailu raczej nie wystepują polskie litery.
Wiem że marudzę, ale jednak smile.gif

Pozdrawiam
Go to the top of the page
+Quote Post
mike
post
Post #4





Grupa: Przyjaciele php.pl
Postów: 7 494
Pomógł: 302
Dołączył: 31.03.2004

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


Cytat(miedzna @ 2005-11-17 11:34:15)
Mocny jesteś smile.gif )

Hehe, tak się składa, że JavaScript znam bardzo słabo winksmiley.jpg

Możesz użyć funkcji replace() do podmiany znaków.
Go to the top of the page
+Quote Post
miedzna
post
Post #5





Grupa: Zarejestrowani
Postów: 401
Pomógł: 1
Dołączył: 10.03.2004
Skąd: Warszawa

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


Znalazłem coś takiego, ale nie wiem jak te 2 scrypty powiązać między sobą:

<script LANGUAGE="JavaScript">
var thisString;
function startText() {
thisString = document.niePolskie.box1.value;
thisString = thisString.replace(/ą/g, "a");
thisString = thisString.replace(/Ą/g, "A");
thisString = thisString.replace(/ś/g, "s");
thisString = thisString.replace(/Ś/g, "S");
thisString = thisString.replace(/ę/g, "e");
thisString = thisString.replace(//g, "E");
thisString = thisString.replace(/ć/g, "c");
thisString = thisString.replace(/Ć/g, "C");
thisString = thisString.replace(/ź/g, "z");
thisString = thisString.replace(/Ź/g, "Z");
thisString = thisString.replace(/ż/g, "z");
thisString = thisString.replace(/Ż/g, "Z");
thisString = thisString.replace(/ó/g, "o");
thisString = thisString.replace(/Ó/g, "O");
thisString = thisString.replace(/ń/g, "n");
thisString = thisString.replace(/Ń/g, "N");
thisString = thisString.replace(/ł/g, "l");
thisString = thisString.replace(/Ł/g, "L");
document.niePolskie.box2.value=thisString;
}
</script>
  1. <form name="niePolskie">
  2. <input type="text" name="box1">
  3. <br>
  4. <input type="text" name="box2">
  5. <br>
  6. <input type="button" value="Convert" onclick="startText();">
  7. </form>
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 - 08:55