Deschidere in iframe adresa selectata in formular

Discutii si intrebari legate de scripturi si functii JavaScript, jQuery si Ajax, cod JavaScript in general.
MelecaCristian
Mesaje:176

Deschidere in iframe adresa selectata in formular

Buna am si eu o problema :(

am urmatorul script editat partial... dar vreau sa imi intre url-ul intr-un iframe acum se deschide url in pagina si nu stiu cum sa il fac sa se deschida intr-un iframe ... cel cu CHECKED este preferatul si sa se deschida primul ...

Cod: Selectaţi tot

<form action="../">

    <input type="RADIO" value="http://www.yahoo.com/"  CHECKED name="userChoice" id="navRadio01">
        <label for="navRadio01">Server 1</label>
		
    <input type="RADIO" value="http://www.google.com/"    name="userChoice" id="navRadio02">
        <label for="navRadio02">Server 2</label>
		
    <input type="RADIO" value="http://www.altavista.com/" name="userChoice" id="navRadio03">
        <label for="navRadio03">Server 3</label>
		
    <input type="RADIO" value="http://www.amazon.com/"    name="userChoice" id="navRadio04">
        <label for="navRadio04">Triller</label>
		
    <input type="RADIO" value="http://artlung.com/"       name="userChoice" id="navRadio05">
        <label for="navRadio05">Descarca</label>

<input type="BUTTON"
    value="Ruleaza"
    onclick="ob=this.form.userChoice;for(i=0;i<ob.length;i++){
    if(ob[i].checked){window.open(ob[i].value,'_top');};}"></p>
</form>
Multumesc tuturor celor care ma ajuta o zi frumoasa :)
„Uneori o greşeală poate fi tot ce este necesar pentru o realizare valoroasă.” — Henry Ford

MarPlo Mesaje:4343
Vezi scriptul urmator (la mine Google nu merge deschis in iframe):

Cod: Selectaţi tot

<div id="adifr"></div>
<form action="../" method="post">
<input type="radio" value="http://www.yahoo.com/"  checked name="userChoice" id="navRadio01" //>
 <label for="navRadio01">Server 1</label>
<input type="radio" value="http://www.google.com/" name="userChoice" id="navRadio02" />
 <label for="navRadio02">Server 2</label>
<input type="radio" value="http://www.altavista.com/" name="userChoice" id="navRadio03" />
 <label for="navRadio03">Server 3</label>
<input type="radio" value="http://www.amazon.com/" name="userChoice" id="navRadio04" />
 <label for="navRadio04">Triller</label>
<input type="radio" value="http://artlung.com/" name="userChoice" id="navRadio05" />
 <label for="navRadio05">Descarca</label> <input type="button" value="Ruleaza" onclick="openIframe(this.form);" />
</form>
<script type="text/javascript"><!--
function openIframe(frm) {
  // preia butoanele radio "userChoice", parcurge si adauga un iframe cu adresa selectata
  var radiobt = frm.userChoice;
  for(i=0; radiobt.length; i++){
    if(radiobt[i].checked == true) {
      document.getElementById('adifr').innerHTML = '<iframe src="'+radiobt[i].value+'" width="700" height="400" align="center" scrolling="yes" frameborder="0" name="nume_frame"> </iframe>';
      break;
    }
  }
}
--></script>

Subiecte similare