i’m just trying to post a form’s text input into an iframe with a return, no submit button.
function changesrc(main, url) {
document.getElementById('main').setAttribute('src', url);
}
my main iframe
<div id="frame"><iframe id="main" name="main" type="text/html" src="" frameborder="0" allowtransparency="true"></iframe>
the actual text input parent form is what is throwing me off…
<form id="url" onSubmit='changesrc('main', target)' method="post"><div id=target><input type="text" name="target" id="target" size="65"></div></form>
pls no implications or degradations, i know this code is lousy…
thanks
There’s a couple of obvious problems with the code you posted:
Also, to access the
srcof themainelement, simply use dot-notation, which results in the following:In the above function you should either use the argument supplied to the function as the string in the
document.getElementById()or the string (as you currently are), but if you’re passing the argument you should probably use it (otherwise there’s no point).In this you’ve tried to quote the string within the string using the same string-delimiters. To get around that problem you should use single-quotes within a double-quote delimited string:
Or double-quotes wtihin a single-quote delimited string:
The
actionattribute is used to specify to where the form data should be submitted, such as a server-side script; not for client-side event-handling; if you must use in-line event handling, you should use theonkeypressevent-handler: