eapro
08-15-2008, 06:58 AM
I don't know if this is the best way to do it but I needed script to get the SRC of the iframe on my page and send it to server via Ajax...I found the below script and modified it...
I know how to send form elements but how do I send the myFrameUrl variable? I was thinking of putting it in a hidden input but can't figure out how?...<html>
<head>
<title>AJAX Example</title>
<script src="prototype-1.3.1.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
function send(){
var params = Form.serialize($('myForm'));
new Ajax.Updater('updateDiv', 'backend.php', {asynchronous:true, parameters:params});
}
var myFrameUrl = document.getElementById('myFrame').src;
</script>
<div id="updateDiv"></div>
<iframe id="myFrame" src="http://google.com/" height="200px" width="200px"></iframe>
<form id="myForm">
<input name="myFrameUrl" type="hidden"><br>
<input name="sendbutton" type="button" value="Send" onClick="send();">
</form>
</body>
</html>
I know how to send form elements but how do I send the myFrameUrl variable? I was thinking of putting it in a hidden input but can't figure out how?...<html>
<head>
<title>AJAX Example</title>
<script src="prototype-1.3.1.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
function send(){
var params = Form.serialize($('myForm'));
new Ajax.Updater('updateDiv', 'backend.php', {asynchronous:true, parameters:params});
}
var myFrameUrl = document.getElementById('myFrame').src;
</script>
<div id="updateDiv"></div>
<iframe id="myFrame" src="http://google.com/" height="200px" width="200px"></iframe>
<form id="myForm">
<input name="myFrameUrl" type="hidden"><br>
<input name="sendbutton" type="button" value="Send" onClick="send();">
</form>
</body>
</html>