🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.javascript
Article #50731

Re: jak powiazac radiobutton z <a href>?

#50731
From: soonic
Date: Fri, 22 Apr 2011 10:30
42 lines
2145 bytes
jakby ktoś początkujący stałby przed podobnym problemem to
udało mi się samemu rozwiązać mój problem z pomocą strony
http://www.geekpedia.com/tutorial194_Using-radio-buttons-with-JavaScript.html

po której mój kod (w celu ilustracji opisanego problemu) wygląda tak:

<html>
   <head>
   <style>
     #show { width: 100px; height: 100px; border:1px solid red }
     img {width: 100px; height: 100px;}
   </style>
   <script>
     function show(link) {
       for (i=0; i<document.myform.same.length; i++)
       {
         if (document.myform.same[i].checked==true)
         {
           t=document.myform.same[i].value + '.gif'
         }
       }
       document.getElementById("show").innerHTML ='<img src=' + 
link.href + t + ' alt="">';
       return false; }
   </script>

   </head>
   <body>
   <form name="myform">
     <INPUT TYPE="radio" NAME="same" VALUE="1">temat1<br>
     <INPUT TYPE="radio" NAME="same" VALUE="2">temat2<br>
     <INPUT TYPE="radio" NAME="same" VALUE="3">temat3<br>
   </form>

   <a href="pic01_.jpg" onclick="return show(this)">test1</a>
   <a href="pic02_.jpg" onclick="return show(this)">test2</a>
   <a href="pic03_.jpg" onclick="return show(this)">test3</a>

   <div id="show" ></div>

   </body>
</html>
Technical Details
Message-ID: <iorld3$7h5$1@news.onet.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!agh.edu.pl!news.agh.edu.pl!news.onet.pl!.POSTED!not-for-mail
References: <ioq7nb$k1n$1@news.onet.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!agh.edu.pl!news.agh.edu.pl!news.onet.pl!.POSTED!not-for-mail
From: soonic <xxsoonic@op.pl>
Newsgroups: pl.comp.lang.javascript
Subject: Re: jak powiazac radiobutton z <a href>?
Date: Fri, 22 Apr 2011 12:30:33 +0200
Organization: http://onet.pl
Lines: 42
Message-ID: <iorld3$7h5$1@news.onet.pl>
References: <ioq7nb$k1n$1@news.onet.pl>
NNTP-Posting-Host: 83-238-164-197.ip.netia.com.pl
Mime-Version: 1.0
X-Trace: news.onet.pl 1303468259 7717 83.238.164.197 (22 Apr 2011 10:30:59 GMT)
X-Complaints-To: niusy@onet.pl
NNTP-Posting-Date: Fri, 22 Apr 2011 10:30:59 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; pl; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9
In-Reply-To: <ioq7nb$k1n$1@news.onet.pl>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit