Forum Moderators: open

Message Too Old, No Replies

Targeting an iframe from a JS Submit button

         

kga109

12:13 am on Jul 6, 2005 (gmt 0)

10+ Year Member



Hello - I have a dealer locator form and need to target an iframe when the user hits the submit button. Can someone please help me with the code to do so? I'm assuming its a line that is dropped right into the submit statement?

<input type=submit name=Locate Value="Search">

The project is on hold 'til I get this figured out - thanks for all the help.

Trace

1:29 pm on Jul 6, 2005 (gmt 0)

10+ Year Member



There are a couple of ways of doing this. Personally I would do it like this :

Change your <input type="submit"> to a <input type="button">. I would then use the button to pass the parameters of your form to the iFrame, something like this :

<input type="button" onClick="document.frameName.location.href('results.asp?searchOption1="+txtLabel1.value+"&searchOption2="+txtLabel2.value+"');">

Another way would be to make a form within your Iframe page, add a bunch of hidden fields, then onClick of your button, insert the data into your hidden fields and POST that form.

<script>
document.frameName.form.hiddenField1.value = form.txtLabel1.value;
document.frameName.form.hiddenField2.value = form.txtLabel2.value;
document.frameName.form.submit();
</script>

The syntax of these examples might be a little off, but at least it points you in the right direction.