How to grab the whole value of a text box?
Moderator: General Moderators
-
slipstream
- Forum Commoner
- Posts: 86
- Joined: Fri Apr 19, 2002 8:53 am
- Location: Canada
How to grab the whole value of a text box?
I have a text box like so:
echo 'Enter the new Docket number here <input type="text" size = 30 name="docketNum">';
then in another php file I create my file like this:
$file2=fopen("dockets/".$docketNum.".txt", "a+");
fwrite($file2, "");
fclose($file2);
The problem is, if I call the docket "hello everyone" it will only make a file called "hello.txt" when it should be called "hello everyone.txt". Does that make any sense?
thanks,
echo 'Enter the new Docket number here <input type="text" size = 30 name="docketNum">';
then in another php file I create my file like this:
$file2=fopen("dockets/".$docketNum.".txt", "a+");
fwrite($file2, "");
fclose($file2);
The problem is, if I call the docket "hello everyone" it will only make a file called "hello.txt" when it should be called "hello everyone.txt". Does that make any sense?
thanks,
-
slipstream
- Forum Commoner
- Posts: 86
- Joined: Fri Apr 19, 2002 8:53 am
- Location: Canada
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
You could just do a str_replace():
Mac
Code: Select all
$filename = str_replace(' ', '_', $filename);-
slipstream
- Forum Commoner
- Posts: 86
- Joined: Fri Apr 19, 2002 8:53 am
- Location: Canada
Sorry guys I messed up here. I can create the file fine. It's when the user select the file name from a combo box it only takes the first word.
ex.
If my they select "hello there" from the combo box.
Then when I echo my cboDocket variable I only get "hello"
The problem is with the box, not file, sorry.
ex.
If my they select "hello there" from the combo box.
Then when I echo my cboDocket variable I only get "hello"
The problem is with the box, not file, sorry.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
-
slipstream
- Forum Commoner
- Posts: 86
- Joined: Fri Apr 19, 2002 8:53 am
- Location: Canada
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
-
slipstream
- Forum Commoner
- Posts: 86
- Joined: Fri Apr 19, 2002 8:53 am
- Location: Canada
Sure, here is the html portion.
$file = file('docket.txt'); // returns an array with each line in a new array pos
$totHours = 0;
echo ' Docket Numbers <select name="cboDock" size=1>';
foreach($file as $line)
{
$info = explode('|', $line);
echo '<option value='.$info[0].'> '.$info[0];
//echo "<td>" . $info[0] . "</td>";
}
echo '</select><BR><BR>';
that's where I fil my box and it works. Now here is the PHP where I echo it for a test:
echo $cboDock;
Like I said it will only echo the first word.
$file = file('docket.txt'); // returns an array with each line in a new array pos
$totHours = 0;
echo ' Docket Numbers <select name="cboDock" size=1>';
foreach($file as $line)
{
$info = explode('|', $line);
echo '<option value='.$info[0].'> '.$info[0];
//echo "<td>" . $info[0] . "</td>";
}
echo '</select><BR><BR>';
that's where I fil my box and it works. Now here is the PHP where I echo it for a test:
echo $cboDock;
Like I said it will only echo the first word.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
The problem is that you have no quotes around the value attribute's value - this means that in the source you will have something like this:
and the browser cannot tell that the second value actually belongs to the value attribute. To correct this problem, change:
to
and then the source code for the page will have this in it:
which makes it explicit to the browser what belongs with what.
Mac
Code: Select all
<option value=test value>test valueCode: Select all
echo '<option value='.$info[0].'> '.$info[0];Code: Select all
echo '<option value="'.$info[0].'">'.$info[0].'</option>';Code: Select all
<option value="test value">test value</option>Mac
-
slipstream
- Forum Commoner
- Posts: 86
- Joined: Fri Apr 19, 2002 8:53 am
- Location: Canada