Passing html value to a phpvariable in same page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sobha
Forum Commoner
Posts: 56
Joined: Wed Jul 15, 2009 9:08 pm

Passing html value to a phpvariable in same page

Post 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
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: Passing html value to a phpvariable in same page

Post 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.
shafiq2626
Forum Commoner
Posts: 88
Joined: Wed Mar 04, 2009 1:54 am
Location: Lahore
Contact:

Re: Passing html value to a phpvariable in same page

Post 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>
Post Reply