468,110 Members | 1,794 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,110 developers. It's quick & easy.

form submit??

I can't seem to figure our why this doesn't work. I don't get any errors, it just doesn't submit. Can anyone shed some light.

<?PHP
$var1 = "http://localhost/php/index.php";
$varx = "bruce";
echo "<form name='formx3' method='post'><input type='text'><input type=button value=go onclick=document.formx3.action='".$var1."'; document.formx3.submit();></form>";
?>

I got it working using the following...but I want to know why the above code is not working.
<?PHP
$var1 = "http://localhost/php/index.php";
$varx = "bruce";
echo "<form name='formx2' action='".$var1."'><input type='text'><input type=button value=go onclick=document.formx2.submit();></form>";
?>

TIA
-Bruce
Jul 17 '05 #1
5 3299
Bruce Duncan wrote:
This is a multi-part message in MIME format.

------=_NextPart_000_000A_01C444BA.D9A547B0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I can't seem to figure our why this doesn't work. I don't get any =
errors, it just doesn't submit. Can anyone shed some light.

<?PHP
$var1 =3D "http://localhost/php/index.php";
Bad syntax!
$varx =3D "bruce";
Bad syntax!
echo "<form name=3D'formx3' method=3D'post'><input type=3D'text'><input =
type=3Dbutton value=3Dgo onclick=3Ddocument.formx3.action=3D'".$var1."'; =
document.formx3.submit();></form>";
Bad syntax! ?>

I got it working using the following...but I want to know why the above =
code is not working.
I don't know JavaScript ... your form does not have a submit button!

Maybe you get better answers by posting your plain HTML and JavaScript
to a JavaScript newsgroup.
<?PHP
$var1 =3D "http://localhost/php/index.php";
Bad syntax!
$varx =3D "bruce";
Bad syntax!
echo "<form name=3D'formx2' action=3D'".$var1."'><input =
type=3D'text'><input type=3Dbutton value=3Dgo =
onclick=3Ddocument.formx2.submit();></form>";
Bad syntax!

Your form does not have a submit button. I wonder how this works ???
?> (snip a bunch of seemingly ramdom characters) ------=_NextPart_000_000A_01C444BA.D9A547B0--


--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #2
"Pedro Graca" <he****@hotpop.com> wrote in message
news:2h************@uni-berlin.de...
Bruce Duncan wrote:
This is a multi-part message in MIME format.

------=_NextPart_000_000A_01C444BA.D9A547B0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I can't seem to figure our why this doesn't work. I don't get any =
errors, it just doesn't submit. Can anyone shed some light.

<?PHP
$var1 =3D "http://localhost/php/index.php";


Bad syntax!
$varx =3D "bruce";


Bad syntax!
echo "<form name=3D'formx3' method=3D'post'><input type=3D'text'><input = type=3Dbutton value=3Dgo onclick=3Ddocument.formx3.action=3D'".$var1."'; = document.formx3.submit();></form>";


Bad syntax!
?>

I got it working using the following...but I want to know why the above = code is not working.


I don't know JavaScript ... your form does not have a submit button!

Maybe you get better answers by posting your plain HTML and JavaScript
to a JavaScript newsgroup.
<?PHP
$var1 =3D "http://localhost/php/index.php";


Bad syntax!
$varx =3D "bruce";


Bad syntax!
echo "<form name=3D'formx2' action=3D'".$var1."'><input =
type=3D'text'><input type=3Dbutton value=3Dgo =
onclick=3Ddocument.formx2.submit();></form>";


Bad syntax!

Your form does not have a submit button. I wonder how this works ???
?>

(snip a bunch of seemingly ramdom characters)
------=_NextPart_000_000A_01C444BA.D9A547B0--


I aplogize for the html formatted post...forgot to change the setting back.
Here it is again...if you can help. I didn't write this code...I'm
debugging someone else's badly formatted code!

This code doesn't do anything:
<?PHP
$var1 = "http://localhost/php/index.php";
$varx = "bruce";
echo "<form name='formx3' method='post'><input type='text'><input
type=button value=go onclick=document.formx3.action='".$var1."';
document.formx3.submit();></form>";
?>
This code works, but I want to know why the above code doesn't.
<?PHP
$var1 = "http://localhost/php/index.php";
$varx = "bruce";
echo "<form name='formx2' action='".$var1."'><input type='text'><input
type=button value=go onclick=document.formx2.submit();></form>";
?>
Thanks again in advance...
-Bruce


Jul 17 '05 #3
Bruce Duncan wrote:
I aplogize for the html formatted post...forgot to change the setting back.
Here it is again...if you can help. I didn't write this code...I'm
debugging someone else's badly formatted code!

This code doesn't do anything:
<?PHP
$var1 = "http://localhost/php/index.php";
$varx = "bruce";
echo "<form name='formx3' method='post'><input type='text'><input
type=button value=go onclick=document.formx3.action='".$var1."';
document.formx3.submit();></form>";
?>
This code outputs this HTML (reformatted):

<form name='formx3' method='post'>
<input type='text'>
<input type=button value=go
onclick=document.formx3.action='http://localhost/php/index.php';
document.formx3.submit();>
</form>
This code works, but I want to know why the above code doesn't.
<?PHP
$var1 = "http://localhost/php/index.php";
$varx = "bruce";
echo "<form name='formx2' action='".$var1."'><input type='text'><input
type=button value=go onclick=document.formx2.submit();></form>";
?>


This code outputs this HTML (reformatted):

<form name='formx2' action='http://localhost/php/index.php'>
<input type='text'>
<input type=button value=go
onclick=document.formx2.submit();>
</form>


The differences between the output of the two scripts are:

1. the form in the first script has the attribute method and
the form in the second script has the attribute action

both forms should have method="post" and action="something"
unless JavaScript can replace any of those attributes
2. the first onclick has two instructions -- I really do not know if
JavaScript accepts that.

So, it seems your problem is with JavaScript -- sorry I can't help you.



In plain and simple HTML, we need a submit button to submit the form,
which neither of the scripts produces.

The PHP on both is ok :)

I'd rewrite both of your scripts the same way:

========
<?php
$var1 = 'http://localhost/php/index.php';
$varx = 'bruce';
// the following uses "heredoc" syntax: check it out @
// http://www.php.net/manual/en/language.types.string.php

echo <<<HTML
<form name="formx3" method="post" action="$var1">
<input type="text" name="unnamed_input" value="$varx"/>
<input type="submit" value="go"/>
</form>
HTML;

?>
========

--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #4
Bruce Duncan wrote:
I'm new to PHP...and my previous post was a bit premature.**I've*narrowed
my problem down to this:

I have this very simple form in test1.php

<form name='formx6' action="testz.php?varxy=1">
**<input*type="text">
**<input*type="submit"*value="sub">
</form>

That's more clean and sure:

<form name='formx6' method="post" action="testz.php">
**<input*type="hidden"*name="varxy"*value="1">
**<!--*that*displays*`test_edit`*as*default*string*in*th e*UI*-->
**<input*type="text"*name="anyvar"*value="test_edi t"*size="30"*>
**<input*type="submit"*value="sub"*name="Submit*yo ur*data"*title="Klick
here :)">
</form>
Why is it that the querystring on testz.php looks like:
http://localhost/php/testz.php?


default form method is 'GET'. If you want to hide the `?...`
than use the 'POST' method :=}

cu

================================================== =====
*****-^-******|*B.*Eschrich,*Software*Engineer
****(O.O)*****|*Mobile:*+49*(0)*174*/*88*00*458
-ooo-\-/-ooo- | Office: +49 (0) 89 / 378 24101

eMail: bj*************@schlundmail.de**Don't*shit*where
Home : http://www.eschrich.de.vu*******you*eat*!
================================================== =====
Jul 17 '05 #5
I noticed that Message-ID: <2h************@uni-berlin.de> from Pedro
Graca contained the following:
2. the first onclick has two instructions -- I really do not know if
JavaScript accepts that.

So, it seems your problem is with JavaScript -- sorry I can't help you.


Why the JS anyway? (which won't work if JS is disabled)
Why not just use <input type='submit' value='Go'>

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Terence Parker | last post: by
6 posts views Thread by CJM | last post: by
4 posts views Thread by Stuart Perryman | last post: by
5 posts views Thread by rjames.clarke | last post: by
5 posts views Thread by Navillus | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.