PDA

View Full Version : simple form to pass variables


jackam1
08-02-2006, 01:03 PM
Hi
I have teh simplest form possible to pass a variable from one form to the other.
I can see from teh header that the variable is passed.
I can also print the variable but The 2nd form does not seem to be ake the value, even though I have named it the same.
Can you spot my mistake please.
Also hoow is it possible for teh 2nd form to start executing teh form as if some on has entered it manually.
I include both forms.
many thanks
Jack


form1:

<form name="myform" method="link" action="testpns.php" >
<b>Enter Part Number: </b><input type="text" name="partnumber"><br>

<input type="submit" name="submit" value="submit ">



form2:
<form name = "database" method="POST" action="
<? echo $PHP_SELF;?>">
Enter Part Number: <input type="text" name="partnumber"><br>
<? echo $partnumber;?>
<input type="submit" name="submit" >
</form>

ColdFire
08-02-2006, 01:25 PM
Hi Jack,

I am not sure iof you have posted this in teh right place but i'll help you out :o)

I am not sure why you want to do what you want to do but your problem is your not placing the php variable in the actual text box, you are placing it below the text box.

You need


<form name = "database" method="POST" action="
<? echo $PHP_SELF;?>">
Enter Part Number: <input type="text" name="partnumber" value="<? echo $partnumber;?>"><br>
<input type="submit" name="submit" >
</form>


See the value in the input tag?

As for your second problem, you can auto submit a form by placing the following in between the <head> tags on your page.


<script language="javascript" type="text/javascript">
function submitform() {
document.database.submit();
}
<script>


You can call the above function from a link or body onload etc by using submitform()

jackam1
08-02-2006, 01:38 PM
Hi coldfire
I placed the variable there just to test that it was being transfered ok.
I expected it to automatically go there, since it had the same name.
Your solution is most welcomed and worked a treat. Thanks.
Whiel you are in such a good mood, I don't suppose you could tell me how to open a new window with custom size, from the first form?
Many thanks
Jack

ColdFire
08-02-2006, 02:04 PM
Your welcome jack,

Check out this page http://www.htmlcodetutorial.com/linking/linking_famsupp_73.html for a solution to sending a form to a popup window.

jackam1
08-02-2006, 02:56 PM
Hi
Thanks for taking the time and looking into it for me.
But its too complicated for me. I just one a new window to open , I thought maybe there is a simple command to add.
Thanks anyway.
Jack

ColdFire
08-02-2006, 03:41 PM
^ If you explain exactly what you want then i will try and explain how you do it. Do you want the 1st form to submit to a popup window which has the 2nd form in it?

jackam1
08-03-2006, 04:49 PM
Thanks coldfire. I solved the problem.
jack