Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > PHP

Reply
 
LinkBack Thread Tools Display Modes
Old 07-02-2002, 10:31 PM   #1 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
Passing form data to PHP with Javascript

Any thoughts on how to do this? All I want to be able to do is use JS to create a small popup from within the form, passing the arguments of the form to PHP and MySQL. Here's what I have so far:

form.html
Code:
<html>
<head>
<script language="JavaScript"></script>
...
<form method="post" action="form.php">
...
<input type="submit" name="submit" value="submit"
onclick="window.open('form.php', '', 'width=300, height=300');"></input>
</form>
...
</html>
The form.php file is as you would expect, opens a connection with MySQL and enters the form data, and gives you feedback on what you've just entered. It works fine alone, without using JS at all.

[edit]
I should mention that it does actually open a small 300x300 window, but the variables from the form aren't passed at all to the popup.
[/edit]

Last edited by bdl; 07-02-2002 at 10:43 PM.
bdl is offline   Reply With Quote
Old 07-02-2002, 11:48 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
well this is how i see it:

when you use the javascript in the submit button, it works just like if it was a link outside a form. that button becomes it's own entity.

for example .. if you make an HTML page (not even a php page) that only contains this:
Quote:
<input type="submit" name="submit" value="submit"
you will notice that this button still opens a new page without even having any <form></form> tags around it.

i'm no javascript expert, but i think there is a resize script you can use for the target page. instead of trying to size the form from the button, there is probably a way to resize it from the target page itself.

for example, after the page opens, it will resize itself to the desired dimensions:
Quote:
<body onLoad="resizeTo(600,400);">
that would be your body tag obviously, but i could not find how to remove the toolbar from the page itself .. and not the link from the previous page. .. i looked for a while but could not find a thing.

goood luck, let me know how it goes.
sde is offline   Reply With Quote
Old 07-03-2002, 07:08 AM   #3 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
try putting your javascript in your <form> tag
__________________


Urban Clothing
Admin is offline   Reply With Quote
Old 07-03-2002, 07:12 AM   #4 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
Quote:
Originally posted by Admin
try putting your javascript in your <form> tag
I thought about that, also. Maybe something like
Code:
<form method="post" action="javascript{onclick="window.open()";}">
[update]

This method is no go also. Thanks for the ideas.

[/update]

Last edited by bdl; 07-03-2002 at 07:15 AM.
bdl is offline   Reply With Quote
Old 07-03-2002, 08:35 AM   #5 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
Quote:
This method is no go also. Thanks for the ideas.
hey, did you try my suggestion? i tested it and it works, except you just have to deal with a toolbar.

the form you have to send it from has to look like this:
<form method=post action=nextpage.html target=new>
<input type=text><input type=submit>
</form>

the key is "target=new" , .. but you probably don't want the toolbar.
sde is offline   Reply With Quote
Old 07-03-2002, 10:18 AM   #6 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
Quote:
Originally posted by mmilano

hey, did you try my suggestion? i tested it and it works, except you just have to deal with a toolbar.

the form you have to send it from has to look like this:
<form method=post action=nextpage.html target=new>
<input type=text><input type=submit>
</form>

the key is "target=new" , .. but you probably don't want the toolbar.
Thanks for the tip; that works just about as well as what I intended. There are parms you can pass to 'window.open' to tell it to leave off the toolbar, menu, etc. I may be able to pass the same arguments to this function, I'm gonna do a little more research. Still testing...
bdl is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
help out a numptie... javascript and php and pop-ups and stuff trogette HTML, XML, Javascript, AJAX 5 10-11-2004 10:11 AM
javascript riddle: why won't my form submit from this text link? sde HTML, XML, Javascript, AJAX 6 09-29-2004 05:56 AM
php script that can upload binary data infinite_root PHP 9 08-27-2004 06:03 PM
Using javascript to submit a form sammy HTML, XML, Javascript, AJAX 2 07-15-2004 01:31 PM
HTML form preview then INSERT using PHP & MySQL SteveSoler PHP 5 07-07-2002 09:54 AM


All times are GMT -8. The time now is 04:46 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting