The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Passing Variables To Onsubmit using a FORM, Trying to pass a FORM input to onsubmit and not working
voodoo98_ca
post Mar 25 2009, 10:22 AM
Post #1





Group: Members
Posts: 1
Joined: 25-March 09
Member No.: 8,152



Hi There,

First off I wasnt sure which category I should put this problem since its using FORMS, and javascript. So I decided to be a bit more generic and put it under HTML.

Anyhow, I'm trying to pass a textual input into a procedure that I want to run when the user hits the enter key.
Basically the screen waits for the user to enter in the name for a new database to be entered and then that is passed to mysql procedure that will create this new database however, the below code does not work.
Im totally stumped. Can someone please shed some light on what Im doing wrong??


echo "<span><form action=\"index.php\" onsubmit=\"ajax_request('create_db_mysql.php');\" method=\"post\"></span>";
echo "<span><input type=\"text\" name=\"create_db_name\"></span>";
echo "<span></form></span>";

Thanks.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Mar 25 2009, 12:07 PM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



I move it to client side scripting. smile.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 25 2009, 02:31 PM
Post #3


.
********

Group: WDG Moderators
Posts: 9,656
Joined: 10-August 06
Member No.: 7



If it's the javascript/AJAX that doesn't work you may have to show the script for us. Also try adding a "return false" after the JS function call to suppress the form from submitting to index.php:

CODE
onsubmit="ajax_request('create_db_mysql.php'); return false;"


BTW the following looks like PHP:

CODE
echo "<span><form action=\"index.php\" onsubmit=\"ajax_request('create_db_mysql.php');\" method=\"post\"></span>";
echo "<span><input type=\"text\" name=\"create_db_name\"></span>";
echo "<span></form></span>";

but the resulting HTML is invalid due to improper nesting of elements (removing all the SPAN tags should fix that part).




User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 25th April 2024 - 11:19 PM