Page 1 of 1

Passing html value to a phpvariable in same page

Posted: Wed Jul 29, 2009 6:57 pm
by sobha
Hi,

How to pass the value of course in form1 to item_name in form f2 as a php variable?

<form action="" name="f1">
<input type="radio" align="middle" name="course" value="A">
<input type="radio" align="middle" name="course" value="B">
<input type="radio" align="middle" name="course" value="C">
</form>
<form action="" name="f2">
<input type="hidden" name="item_name" value=<?php $value?> />
</form>

Please help

Regards,
Sobha

Re: Passing html value to a phpvariable in same page

Posted: Thu Jul 30, 2009 1:55 am
by cpetercarter
I think that you want the value of "item_name" to be A, B or C, depending on which radio button is clicked. Is this right? You can't use normal php/html to pass this value if forms f1 and f2 are on the same web page. You could use JavaScript, however. But I wonder if you would not do best to rethink the programme logic so that the server takes the value from "course" and then uses it in for whatever purpose you need.

Re: Passing html value to a phpvariable in same page

Posted: Thu Jul 30, 2009 2:03 am
by shafiq2626
[quote="sobha"]Hi,

How to pass the value of course in form1 to item_name in form f2 as a php variable?

<form action="" name="f1">
<input type="radio" align="middle" name="course" value="A">
<input type="radio" align="middle" name="course" value="B">
<input type="radio" align="middle" name="course" value="C">
</form>
<form action="" name="f2">
<input type="hidden" name="item_name" value=<?php $value?> />
</form>


helow
you should have to submit first form and then this can be pass value to second form like this
<form action="" name="f2">
<input type="hidden" name="item_name" value=<?php echo $_POST['course'];?> />
</form>