PDA

View Full Version : saving value of a text field



antz
Jun 29th, 2007, 04:46 AM
Gday

First off - i know its not really a good practice to have a question as your first post, i browsed through the forum trying to answer at least one question for someone, but javascript isnt my strong point and i couldnt contribute just yet. However if someone is kind enough to help me out with this problem ive been having, ill be very grateful.

Problem is quite simple i think: I have a small page, which contains the following form:


<form method="post" action="shoutbox.php?action=new" name="form1">
<table width="100%">
<tr>
<td width="8%">Name</td>
<td width="92%">
<input tabindex=1 type="text" name="name" class="namebox-txt" /><input tabindex=3 type="submit" name="Submit" value="Submit" class="shoutbox-btn" />
</td>
</tr>
<tr>
<td>Message</td>
<td><input tabindex=2 name="message" type="text" class="shoutbox-txt" maxlength="100"/></td>
</tr>
</table>
</form>

the purpose of this form is to collect a user name, and user's message, and then it passes it into a .txt file which acts as a "database" for a small chatbox.

Everything works fine, apart from one inconvenient detail - every time the form page gets refreshed (which happens after they push submit), the name dissapears, and users have to keep retyping their name. I tried mucking around with creating a cookie and calling the name from there, but i couldnt get my head around it. Apparently there is a way of storing a value temporarily even without using cookies?

Any help would be appreciated.


Thanks.

rwedge
Jun 29th, 2007, 05:40 AM
These two pages from the MSDN site show an alternative
http://msdn2.microsoft.com/en-us/library/ms533010.aspx
http://msdn2.microsoft.com/en-us/library/ms533015.aspx
I'm not sure how cross-compatible it is though

Since you are using php, it my be better to handle this server side.

antz
Jun 29th, 2007, 06:12 AM
Oh wicked thanx mate. Ill get onto that now and will post if it works. Looks like it should though.

FJbrian
Jun 29th, 2007, 06:18 AM
FWIW I think you call that a "flat file" database