Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
06-01-2005, 11:56 AM
|
#1
|
|
Member
Registered: Jun 2004
Location: PA
Distribution: Fedora Core 8_x86 (latest git kernel)
Posts: 434
Rep:
|
submit a form with javascript
hello,
i have a question about javascript. I want a user to click on a button which brings up a new window. That part is easy, i know how to implement that, but my trouble is in the new window i want to be able to make a form and be able to submit that form to either a database or another link. is this possible with javascript?????
let me know it this isn't clear enough
thanks,
djgerbavor3
|
|
|
|
06-01-2005, 12:40 PM
|
#2
|
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
Yes. You just need to execute "document.FORM_NAME.submit()" when you want the data to be submitted.
|
|
|
|
06-01-2005, 02:09 PM
|
#3
|
|
Member
Registered: Jun 2004
Location: PA
Distribution: Fedora Core 8_x86 (latest git kernel)
Posts: 434
Original Poster
Rep:
|
i'm alittle confuse.
how would i do that.
i have a funtion that pops ups a new window were the form is going to be.
Code:
function form_window() {
newWin = window.open("", "toolbar=yes, width=650, height=600, resizable=yes");
newWin.document.write( /*put the form code here*/);
//add a submit button
var submitButton = newWin.document.createElement("input");
submitButton.setAttribute("type", "submit");
submitButton.setAttribute("value", "Submit");
newWin.document.body.appendChild(submitButton);
}
how would i include document.FORM_NAME.submit(), so when i click on the submit it will take me to a new page?????
thanks,
djgerbavor3
|
|
|
|
06-01-2005, 02:17 PM
|
#4
|
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
If your form actually has a submit button then you don't need to use javascript to submit it. Just set the action variable in the form to be the page you are taken to - ie:
<form action="myscript.php">
|
|
|
|
06-01-2005, 02:31 PM
|
#5
|
|
Member
Registered: Jun 2004
Location: PA
Distribution: Fedora Core 8_x86 (latest git kernel)
Posts: 434
Original Poster
Rep:
|
okay here is what i have:
Code:
function form_window() {
newWin = window.open("", "toolbar=yes, width=650, height=600, resizable=yes");
newWin.document.write("<form action=\"foo.php\" method='POST'>");
newWin.document.write( /*put the form code here*/);
//add a submit button
var submitButton = newWin.document.createElement("input");
submitButton.setAttribute("type", "submit");
submitButton.setAttribute("value", "Submit");
newWin.document.body.appendChild(submitButton);
newWin.document.write("</form>");
}
when i click on the submit button nothing happens, and i checked mozilla's javascript console and it doesn't show any errors??? Am i doing something wrong??
thanks for you time,
djgerbavor3
|
|
|
|
06-01-2005, 02:38 PM
|
#6
|
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
My only guess is that the submit button is not being written within the form - try using:
newWin.document.write("<input type=\"submit\" value=\"Submit Form\">");
newWin.document.write("</form>");
|
|
|
|
06-01-2005, 02:46 PM
|
#7
|
|
Member
Registered: Jun 2004
Location: PA
Distribution: Fedora Core 8_x86 (latest git kernel)
Posts: 434
Original Poster
Rep:
|
hahah that worked!!!!!!!!!!! i can't believe i didn't know that  oh well you learn something new every day. Thanks for you help.
djgerbavor3
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:37 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|