PDA

View Full Version : display hidden iFrame onclick



balanca
12 May 2008, 10:27 AM
Hello,
I have a problem with Javascript. I am trying to show a hidden iFrame when user submits form. I am new in php and javascript .....please help
here is the code
javascript in head section of html
<script type="text/javascript">
<!--
function hideMe(){
// Hide or show iframe

if(document.getElementById("myframe").style.visibility=="visible"){
document.getElementById("myframe").style.visibility="hidden"
}
else{
document.getElementById("myframe").style.visibility="visible"
}
//-->
</script>

body

<input name="shrani" type="submit" id="shrani" value="Shrani" onclick="hideMe()"/>
<iframe id="myframe" width="100%" src="vnosPozicija.php" style="visibility:hidden"></iframe>

carrathanatos
03 Jun 2008, 03:54 PM
try this instead:

javascript in head section of html
<script type="text/javascript" language="Javascript">
<!--
function hideMe(){
// Hide or show iframe

if(document.getElementById("myframe").style.visibility = "visible"){
document.getElementById("myframe").style.visibility = "hidden";
}
else{
document.getElementById("myframe").style.visibility =" visible";
}
}
//-->
</script>

body

<input name="shrani" type="submit" id="shrani" value="Shrani" onclick="hideMe()" />
<iframe id="myframe" width="100%" src="vnosPozicija.php" style="visibility:hidden;">Alternate I-frame content here!</iframe>

---

I just made a few changes to yours (extra "=", missing ";", missing "}")... I used code similar to that to hide elements in a div tag.

Hope that helps! :)