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 :