Page 1 of 1

submit and reload with iframe

Posted: Wed Sep 09, 2009 6:27 am
by Xpistiva
I have dynamic drop down lists, that changes depending on each other. I also want an iFrame to change when i change one of the drop down lists.
The reload works fine and also the submit if they are done separately. But together the iframe doesn’t reload with the new values. It seems like the site is reloaded after the submit.

How can I perform these two actions together?

Code: Select all

<script language=JavaScript>
function reload(form, typ){
var typ;
if(typ=="produkt") var val=form.produkt.options[form.produkt.options.selectedIndex].value;
else if(typ=="produkt2") var val=form.produkt2.options[form.produkt2.options.selectedIndex].value;  
else if(typ=="grupp") var val=form.grupp.options[form.grupp.options.selectedIndex].value;
else if(typ=="kurs") var val=form.kurs.options[form.kurs.options.selectedIndex].value;
else if(typ=="fraga") var val=form.fraga.options[form.fraga.options.selectedIndex].value;
else if(typ=="datum") var val=form.datum.options[form.datum.options.selectedIndex].value;
var urlHalves = String(self.location).split('?');
 
if(urlHalves[1]){
self.location=self.location +'&' + typ + '=' + val;
}
else{
self.location=self.location +'?' + typ + '=' + val;}
return true;
}
</script>
 
<form action="graf4.php" class="form1" method="post" target="grafFrame">
 
<select name="fraga"  WIDTH="430" STYLE="width: 430px" onchange='reload(this.form, "fraga"); this.form.submit();'>
...
<select name="datum" onchange='reload(this.form, "datum"); this.form.submit();'> 
...
<iframe name="grafFrame" src ="graf4.php" width="430px" height="350px" frameborder="0">
  <p>Your browser does not support iframes.</p>
</iframe>

Re: submit and reload with iframe

Posted: Wed Sep 09, 2009 1:49 pm
by kaszu
To do both you need to change "action" of the form instead of self.location ('self' is not defined in your code) and then submit form.