Re: [PHP] Javascript and $_POST
- From: admin@xxxxxxxxxx (T . Lensselink)
- Date: Thu, 8 Feb 2007 16:00:14 +0100
Don't see how this can pass the check without document.
if (inputForm.cc_phone_number.value == "") {
alert( "Please enter a phone number." );
inputForm.cc_phone_number.focus();
return;
}
Comming to this check already gives an error.
Maybe ask on some Javascript list.
P.s. reply to the list please.
On Thu, 8 Feb 2007 09:45:59 -0500, "Dan Shirah" <mrsquash2@xxxxxxxxx> wrote:
Okay, here is ALL of my checkForm() function..
function checkForm() {
***This check passes***
if (inputForm.cc_phone_number.value == "") {
alert( "Please enter a phone number." );
inputForm.cc_phone_number.focus();
return;
}
***This check passes***
if (inputForm.receipt.value == "") {
alert( "Please select whether or not a receipt was requested." );
inputForm.receipt.focus();
return;
}
***This check passes***
if (inputForm.case_number.value == "") {
alert( "Please enter a case number." );
inputForm.case_number.focus();
return;
}
***This check passes***
if (inputForm.cc_first_name.value == "") {
alert( "Please enter a first name." );
inputForm.cc_first_name.focus();
return;
}
***This check passes***
if (inputForm.cc_last_name.value == "") {
alert( "Please enter a last name." );
inputForm.cc_last_name.focus();
return;
}
***This check passes***
if (inputForm.cc_middle_name.value == "") {
alert( "Please enter a middle name." );
inputForm.cc_middle_name.focus();
return;
}
***This check passes***
if (!(document.inputForm.cc_comments.value =="")) {
if (document.inputForm.cc_comments.value.length > 250)
{
alert("The Comments must be less than 250 characters.\nIt is currently
"
+ document.inputForm.window_name.value.length + " characters.");
document.inputForm.window_name.focus();
return;
}
}
***Error: Object doesn't support this property or method.
Code: 0***
document.inputForm.submit();
}
//-->
</script>
On 2/8/07, T. Lensselink <admin@xxxxxxxxxx> wrote:
ways...
There is nothing wrong with the way you want to submit this form.
Although it's JS :) The sample code you posted was broken in some
data.
missing document. in JS en missing input field to check.
This sample works fine ...
test.html
<script language="JavaScript">
function checkForm() {
if (document.inputForm.cc_phone_number.value == "") {
alert( "Please enter a phone number." );
document.inputForm.cc_phone_number.focus();
return;
}
document.inputForm.submit();
}
</script>
<title></title>
<LINK rel="style***" type="text/css" href="../../CSS/background.css">
</head>
<body>
<div align="center">
<h2></h2>
<h3>Submit a New Payment.</h3>
</div>
<form name="inputForm" action="save.php" method="post"
enctype="multipart/form-data">
<input type="text" name="cc_phone_number" value="8756765756757" />
<table align="center" border="0" cellpadding="0" cellspacing="0"
width="680">
<tr>
<td width="64" align="left"><a href="javascript:checkForm()"
title="Save">Save</a></td>
<td width="616" align="left"><a href="javascript:closeThis()"
title="Close">Close</a></td>
</tr>
</table>
</form>
</body>
</html>
save.phhp
<?php print_r($_POST); ?>
Think some other code or JS errors might stop the form from sending
wrote:
On Thu, 8 Feb 2007 09:09:34 -0500, "Dan Shirah" <mrsquash2@xxxxxxxxx>
wrote:
Nope, same result unfortunately.add
On 2/8/07, Németh Zoltán <znemeth@xxxxxxxxxxxxxx> wrote:
On cs, 2007-02-08 at 08:56 -0500, Dan Shirah wrote:
Okay, I'll try your spacer solution. Where do you think I should
checkForm()it?
I put it right before the </form> tag, but I think you could put it
anywhere between the <form> and the </form>
greets
Zoltán Németh
On 2/8/07, Németh Zoltán <znemeth@xxxxxxxxxxxxxx> wrote:
On cs, 2007-02-08 at 08:41 -0500, Dan Shirah wrote:
> I should not need an actual Button if my link to
submit,ends with
> document.inputForm.submit(); which tells the form to
theright?
well, you should be right...
but I remember a year ago or so I had a similar problem and
the image
input solved it... but I'm not sure whether it was exactly
same
problem or not, so it might be complete bull*** ;)
greets
Zoltán Németh
>
> On 2/8/07, Németh Zoltán <znemeth@xxxxxxxxxxxxxx>
wrote:> On cs, 2007-02-08 at 08:14 -0500, Dan Shirah
cellpadding="0"for> > Okay, I edited my page per some suggestions
here. Below is
> what I now have:
> >
> >
> > <script language="JavaScript">
> > function checkForm() {
> >
> > // ** START **
> > if (inputForm.cc_phone_number.value == "") {
> > alert( "Please enter a phone number." );
> > inputForm.cc_phone_number.focus();
> > return;
> > }
> >
> > ******Lots of other checks here, just left out
> length******
> >
> > document.inputForm.submit();
> > }
> >
> > </script>
> > <title></title>
> > <LINK rel="style***" type="text/css"
> href="../../CSS/background.css">
> > </head>
> > <body>
> > <div align="center"> <h2></h2>
> > <h3>Submit a New Payment.</h3>
> > </div>
> > <form name="inputForm" action="save.php"
method="post"
> > enctype="multipart/form-data">
> >
> > ******Lots of form data here******
> >
> > <table align="center" border="0"
helped,of> cellspacing="0"
> > width="680">
> > <tr>
> > <td width="64" align="left"><a
> href="javascript:checkForm()"
> > title="Save">Save</a></td>
> > <td width="616" align="left"><a
> href="javascript:closeThis()"
> > title="Close">Close</a></td>
> > </tr>
> > </table>
> > </form>
> > </body>
> > </html>
> >
> > Now when I submit my page it still perfroms all
the
> javascript checks
> > correctly, but once it gets to the
> document.inputForm.submit(); part it
> > returns the following error.
> >
> > Error: Object doesn't support this property or
method.
> > Code: 0
> >
>
> maybe because you don't have submit button in the
form?
> try to include something like this
> <input type="image" src="./images/spacer.gif">
> where spacer.gif is an 1x1 blank image
>
> I remember some similar situation where it
validatebut I'm not
> sure
>
> hope that helps
> Zoltán Németh
>
> >
> >
> > On 2/7/07, Paul Novitski
<paul@xxxxxxxxxxxxxxxxxxx> wrote:
> > >
> > > At 2/7/2007 01:34 PM, Dan Shirah wrote:
> > > >I have a form that uses Javascript to
theform field
> entries, and if
> > > >they are incorrect it returns an error to
areituser.
> > > >
> > > >After the Javascript processing is complete,
processingsubmits
> the form to my
> > > save
> > > >page. However it seems that once the
is
> complete and it passes
> > > to
> > > >the save page, none of my $_POST variables
Thebeing
> passed.
> > >
> > >
> > > Of course, all of your form fields need to be
inside the
> same
> > > <form></form> tags as your submit button.
sample HTML
> you posted
> > > did not indicate that you'd done this.
> > >
> > > Regards,
> > >
> > > Paul
> > > __________________________
> > >
> > > Paul Novitski
> > > Juniper Webcraft Ltd.
> > > http://juniperwebcraft.com
> > >
> > >
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
- Prev by Date: Re: [PHP] Javascript and $_POST
- Next by Date: Re: [PHP] is_dir reading a folder with a space in the name?
- Previous by thread: is_dir reading a folder with a space in the name?
- Next by thread: Boolean-cast and arrays
- Index(es):