SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
Sep 12, 2005, 22:37 #1
- Join Date
- Jun 2003
- Location
- San Francisco
- Posts
- 119
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Can I combine document.form.submit with window.open?
I have a form with two submit buttons. One button works like a regular submit button and inserts a new record in a db. The second is a "preview" button. What I'd like to do when the Preview button is clicked is have the form contents posted into a popup window. Is this possible?
My current code:
PHP Code:<script type="text/javascript">
function submitFunction(i) {
if (i==1) document.form.action=
"preview.php";
if (i==2) document.form.action=
"insertrecord.php";
document.form.submit()
}</script>
<input type="submit" name="Preview" value="Preview" onClick="submitFunction(1)">
<input type="submit" name="Publish" value="Publish" onClick="submitFunction(2)">
Thanks,
JulianOnline stores, database websites, and hosting by Crunch42.
-
Sep 12, 2005, 22:43 #2
- Join Date
- Jun 2003
- Location
- San Francisco
- Posts
- 119
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Figured it out...
In case it helps anyone else:
PHP Code:<script type="text/javascript">
function submitFunction(i) {
if (i==1) { document.form.action= "preview.php";
document.form.target = '_new';
document.form.submit() }
if (i==2) { document.form.action="insertrecord.php";
document.form.submit() }
}
</script>
<input type="submit" name="Preview" value="Preview" onClick="submitFunction(1)">
<input type="submit" name="Publish" value="Publish" onClick="submitFunction(2)">
Online stores, database websites, and hosting by Crunch42.
-
Dec 15, 2005, 09:43 #3
- Join Date
- Oct 2000
- Posts
- 407
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
This is exactly what I was looking for as well.
Thanks for posting the answer
Bookmarks