anyone knows how can I send variables from a php page to a form - i need to fill the form with these variables ?
maybe using (the process of passing variables to other pages - through url)
but how can i assign them to form variables ?
Moderator: General Moderators
coool wrote:maybe using (the process of passing variables to other pages - through url)
but how can i assign them to form variables ?
Code: Select all
// page.php?foo=value
<input type="text" name="foo" value"<?php echo isset($_GET['foo']) ? $_GET['foo'] : '';?>" />Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
[b]page.php[/b]Code: Select all
<?php
$items = "item1,item3";
?>
<a href="form.php?selectedItems=<?=$items?>" >View Form<a/>Code: Select all
<form name="selectionform" method="post" action="">
<select size="3" multiple name="selectedItems[]">
<option value="item1">Item1</option>
<option value="item2">Item2</option>
<option value="item3">Item3</option>
</select>
<input type="submit" value="View Result">
</form>Code: Select all
if($_POST)
echo implode($_POST['selectedItems'],",");Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]How do you determine which should be pre-selected? Database? A different form? Is it the same every time?coool wrote:What I'm looking for is when user click "View Form" link, they get the for filled with items - i.e some items are alreay selected ---- then if the user want to deselect one of the items or select more items he should able to do that.. !
... No.coool wrote:can you take my sample code and add to it the proper things so it will work ! please
Then make one. If they can select data, why wouldn't you make it a form? How else did you expect to pass the data?coool wrote:but I don't have a form in my first page to use a submission button
print_r($_POST) and work from there.coool wrote:and then even if i do that how can i handle the selected items/things in the form (second page)