Page 1 of 1

passing post in htm as variable into another form

Posted: Sat Feb 26, 2011 2:06 pm
by gjwolf1
I have an hml page that uses option values and lets the user select values. the values are php pages which when they submit pass the chosen value to the next page I show a snip below. I wanted to have the form action grab the formVar passed to it- but I can't seem to get it going. I figure I just may not be putting the post in correctly- any help appreciated

I have two pages page1 and page 2 page 1 does the following. since I have a page i want to call (page2_test_html) with all 3 options
I want page2 to be passed the option value(another page) so when a user fills out page2 they will hit submit and get to the page.


page1 is as follows:

<html>
<select onchange="document.myform.formVar.value=this.value">
<option value="newtest.php">poe</option>
<option value="newtest1.php">non poe</option>
<option value="newtest2.php">non poe 24/option>
</select>
<form method=post name="myform" action="page2_test.html">
<input type="hidden" name="formVar" value="">
<input type="submit" value="Send form!">
</form>


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
page 2 part that im having issues w/ as follows:


<head><title>page2</title></head>
<body>
<form action="<?php $_POST['formVar']; ?>" method="POST">

which doesnt work- I've also tried to pass it to this in these ways as someone else suggesting giving it a try but still doesnt work

tried this way
<form action="<?php echo{$_POST['formVar']}; ?>" method="POST">

and this way w/ no luck

<form action="<?php echo($_POST['formVar']); ?>" method="POST">



any help is greatly greatly appreciated

Re: passing post in htm as variable into another form

Posted: Sun Feb 27, 2011 12:18 am
by social_experiment

Code: Select all

<input type="hidden" name="formVar" value="">
I suspect your problem is here, the javascript passes the value but it's not written to the html page (I could be wrong though, my javascript knowledge is need-to-know-more at the moment). Try hard coding an example value in and see what happens.
You 'select' element isn't wrapped in a form element. Try putting it inside a form.

Code: Select all

<form action="<?php $_POST['formVar']; ?>" method="POST">
// should be
<form action="<?php echo $_POST['formVar']; ?>" method="POST" >
// try this option first ^^