[#] Przekazanie wartości z okna popup do pola input

( Ostatnio zmieniony pon., 02/06/2008 - 01:13 )
 

index.html

<html>
<head>
  <title>popup test</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>

  <form action="" method="POST" name="forma">

     <input maxlength="60" id="PoleInput" size="20" value="" type="text" />
     <input type="button" onclick="window.open('popup.html', 'popup',
                                     'menubar=no, toolbar=no, location=no, directories=no,
                                     status=no, scrollbars=no, width=300, height=200, left=10, top=10').focus();"
              value="Pokaż listę" />
  </form>

</body></html>

script.js

function ret(Val) {

    // metoda 1
    opener.document.getElementById("PoleInput").value = unescape(Val);

   // metoda 2
   //opener.document.forms['forma'].elements['PoleInput'].value = unescape(Val);

  // zamykamy okno
  window.close()
}

popup.html

<html>
<head>
   <title>popup test</title>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <script type="text/javascript" src="script.js"></script>
</head>
<body>

 <a href="javascript:ret('wartosc1')">wartosc1</a> <br />
 <a href="javascript:ret('wartosc2')">wartosc2</a> <br />
 <a href="javascript:ret('wartosc3')">wartosc3</a> <br />
 <a href="javascript:ret('wartosc4')">wartosc4</a> <br />
 <a href="javascript:ret('wartosc5')">wartosc5</a> <br />

</body></html>
3
Twoja ocena: Brak Średnio: 3 (2 głosy)