Page 1 of 1
Value disappears on Refresh
Posted: Sat May 30, 2009 10:20 am
by schwarzwolf
Code: Select all
<form><input type="text" name="readonly-field" readonly onfocus="this.blur()" /><input type="button" value="Add" onClick="N2.value = '<?php echo $_SESSION['username']; ?>', this.disabled=true N7." id="submitN2" /></form>
Well that's the important part of the code, It changes input text value when u click that button but everytime I refresh, that new value disappears, is there a way to keep it there without making a database?
Thx in advance.
Re: Value disappears on Refresh
Posted: Sat May 30, 2009 6:32 pm
by johnd123
im not sure i understand what your refering to: new value disappears
What new value?? do you mean the button value?
Code: Select all
<input type="button" value="Add" onClick="N2.value = '<?php echo $_SESSION['username']; ?>', this.disabled=true N7." id="submitN2" />
if so, ensure you have
session_start(); at the top of the page
if not can you explain in more detail

Re: Value disappears on Refresh
Posted: Sun May 31, 2009 2:36 pm
by schwarzwolf
Code: Select all
<form><input type="text" name="readonly-field" readonly onfocus="this.blur()" /><input type="button" value="Add" onClick="N2.value = '<?php echo $_SESSION['username']; ?>', this.disabled=true" id="submitN2" /></form>
This:onClick="N2.value = '<?php echo $_SESSION['username']; ?>',
That function adds a value to a text field, The value is username, I don't have troubles with that, but I want that value (username) to never disappear because when I refresh page the value is not longer there, I'd like to change value permanently.
I'm making a form for a tournament so when someone logs on and click on add (<input type="button" value="Add") the form will register their name and will stay there untill I erase it, that's the main point of all this.
Re: Value disappears on Refresh
Posted: Sun May 31, 2009 3:01 pm
by mikemike
If you want the field to constantly say the users username until they change it then just have value="<?=$_SESSION['username']?>" in the field attributes:
Code: Select all
<input type="text" name="username" value="<?=$_SESSION['username']?>" />
Re: Value disappears on Refresh
Posted: Sun May 31, 2009 3:30 pm
by schwarzwolf
No Bro, let's do it step by step so you'll get the point:
When Tournament Registration is up:
User Login
He goes to Tournament Page
There is a button that is named Add (it is suppouse to register the username on the tournament bracket field, that field is the text field) and it adds his username on a text field.
Then if he goes to other sites or refresh site, his name will be there still but remember *¡Only If He Clicked The Button!*, that means only if he registered for the tournament.
Now the problem is that on my code he can click the add button and yes his username appears but when page is refreshed the username is gone. So I need to permanently change the value of that text field only if he clicks that button.
I hope it's clear now.
Re: Value disappears on Refresh
Posted: Sun May 31, 2009 3:50 pm
by mikemike
If I'm understanding you right you need to save the value into a database or a cookie - probably cookie if the user isn't registering first.
Re: Value disappears on Refresh
Posted: Sun May 31, 2009 6:45 pm
by schwarzwolf
umm is that the only way? I mean the cookie can be lost when they erase their history and well I got some troubles with my databases that's why Iwas looking another way, maybe something that can really modify the html tags idk.
Re: Value disappears on Refresh
Posted: Sun May 31, 2009 7:10 pm
by mikemike
That would be the two best ways, yeah. I'm sure there are many other far over-complicated methods too though
Re: Value disappears on Refresh
Posted: Mon Jun 01, 2009 9:48 pm
by schwarzwolf
Ok tyvm