Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JS] Wstawianie zmiennej w atrybucie value, Formularz
jepek
post
Post #1





Grupa: Zarejestrowani
Postów: 55
Pomógł: 10
Dołączył: 12.08.2007

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


Witam,

Załóżmy, że mam zmienną

  1. var zmienna = "test";


I chciałbym wstawić ją do atrybuty value pola input

  1. <form id="formularz" name="formularz" action="skrypt.php" method="post">
  2. <input name="pole" type="text" id="pole" />
  3. </form>


Jak to zrobić?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
jepek
post
Post #2





Grupa: Zarejestrowani
Postów: 55
Pomógł: 10
Dołączył: 12.08.2007

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


Szukałem, i robiłem tak jak napisałeś. Niestety nie zmienia mi to wstawia wartości value

  1. <script type="text/javascript">
  2. var zmienna = "test";
  3. document.getElementById("pole").value="abc";
  4. <form id="formularz" name="formularz" action="skrypt.php" method="post">
  5. <input name="pole" type="text" id="pole" />
  6. </form>


Udało się za pomocą:

  1. $('input[name="pole"]').val(zmienna);


Ten post edytował jepek 18.03.2012, 14:23:39
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 6.10.2025 - 03:11