/    Sign up×
Community /Pin to ProfileBookmark

How can I move the item input to a list box after sumit

I would like to know how to move the value entered in a textbox to a list box. I am able to display the first entered value in the text box. I dont know how to display all the values entered in a text box to list box.
Thanks in advance!

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@xvszeroJul 31.2007 — Store each value submitted into a session array and then use the array to populate the list box?
Copy linkTweet thisAlerts:
@kl1980authorJul 31.2007 — I tried this;

$_SESSION['text_name'] = $_POST['text_name'];

but still I am able to store only the first entered value. When I enter another text the second gets replaced by the second text value.
Copy linkTweet thisAlerts:
@bluestarsJul 31.2007 — $_SESSION['arr'] = array();

$_
SESSION['arr'][] = $_POST['text_name'];

Then, the array $_SESSION['arr'] should contain all of the entered values.
Copy linkTweet thisAlerts:
@kl1980authorJul 31.2007 — I tried changing the code. But still I am able to store only the first value of a text. When I try to print the $_SESSION array nothing is getting displayed.
Copy linkTweet thisAlerts:
@kl1980authorJul 31.2007 — This is code:

<?php

$var =& $_SESSION['var'];

switch($_POst['!submit'])

{

case "Cancel":

header( "Location: index.php" );

exit;

break;

case "Generate":

break;
}

?>


<html>

<head>

<title><?=$var ?></title>

<script type="text/javascript">

function StartSearch()

{

document.getElementById("SearchBox").style.visibility = "visible";

}

function Close()

{

var PageRange;

PageRange = null;

document.getElementById("SearchBox").style.visibility = "hidden";

}

</script>


<link href="style.css" rel="stylesheet" type="text/css">

</head>

<div align="right"><a href="exit_page.php">Exit<br></div></a>

<body>

<br>

<form name="screen_form" action= screen_ref_file.php method="POST">

<input type="hidden" name="MAX_FILE_SIZE" value="2000000" />

<table border="0" cellspacing="0" cellpadding="4" align="center">

<tr>

<td align="center">Enter the name of the first file:</td>

</tr>

<tr>

<td align="center"><input type="file" name="file1"></td>

</tr>

<tr><td><br></td></tr>

<tr>

<td align="center">Enter the name of the second file:</td>

</tr>

<tr>

<td align="center"><input type="file" name="file2" ><br></td>

</tr>

<tr><td><br></td></tr>

<tr height=300 width=600 bgcolor="beige">

<td>Folders search configuration<td>

<td>Folders:<td>

<SELECT NAME=sections MULTIPLE>

<OPTION value="">Text values</OPTION>

<?php

session_start();

$_SESSION['arr'] = array();

$_
SESSION['arr'][] = $_POST['folder_name'];

print_r($_
SESSION['arr']);

$folder = array();

$folder= $_SESSION['arr'];

?>

<OPTION value="">

<?php


for($i = 0; $i < count($folder); $i++)

print_r($folder[$i]); ?></OPTION>

</SELECT>

<div id="SearchBox" align = "center" style="position:absolute; width:400px; height:20px;left:100px; border:ridge 3px; padding:3px; color:#DC6000; background-color:#F0F0F0; visibility:hidden">
<b>Enter the Text name:</b>
<input type="text" name="folder_name"/>
<input name = "Oktext" type = "submit" value="Ok"/>
<input type="button" value="Close" onclick="Close()"/>
</div>
<input type="button" value="Add" onclick="StartSearch()">
<input name="!submit" type="submit" value=">>">
Folders sorted:
<SELECT NAME=sections MULTIPLE>
<OPTION>Sorted text values</OPTION>
</SELECT></td>
</tr>
<tr><td><br></td></tr>
<tr>
<td align="center"><input name="!submit" type="submit" value="Generate">
&nbsp;&nbsp;
<input type="reset" value="Clear">
&nbsp;&nbsp;
<input name="!submit" type="submit" value="Cancel"></td>
</tr>
</table>
</form>

</body>

</html>
×

Success!

Help @kl1980 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...