Okay, so I have a PHP/MySQL based site and I'm trying to put together an 'edit your post' page. Basically everything the user previously put in pops up as an html form with disabled fields. Currently I have a Java script activated by a link to remove the 'disable' from an individual field if the user wants to edit it, but I also want to add a 'reset' link to return to the initial values if the user changes his/her mind about one field in the midst of filling out the form.
When the form first pops up, the initial html values are dictated by PHP. By clicking 'edit' they can alter these values, and what I want them to be able to click 'reset' and return to the initial values. However, since PHP is on the server and Java with the client, if I understand things correctly Java can't re-retrieve the PHP values as I did the first time around.
Instead I am curious to find a way with Java read the initial value, remember it, and later, if the user hits 'reset', send it back to the HTML. Below is a piece of my code. Basically I want to replace the "default" in the rest_name_rest function with whatever the output of <?php echo $row[rest_name]?> was when the page was first loaded. Thanks in advance for the help!!!
CODE
<html>
<head>
<script type="text/javascript">
function rest_name_enable(){
if (document.all || document.getElementById){
document.form_name.rest_name.disabled=false}}
</script>
<script type="text/javascript">
function rest_name_reset(){
if (document.all || document.getElementById){
if (document.form_name.rest_name.disabled==false)
{var r=confirm("This will delete whatever you just typed!!" + '\n' +
"Are you sure you want to reset the Restaurant Name?");
if (r==true) {
document.form_name.rest_name.disabled=true
document.form_name.rest_name.value="default"}
else {}}
else {}}}
</script>
</head>
<body>
<form name="form_name">
<input name="rest_name" type="text" value="<?php echo $row[rest_name]?>" disabled="disabled">
<a href = "java script:rest_name_enable()">edit</a>
<a href = "java script:rest_name_reset()">reset</a><br>
</body>
</html>
Moved to JavaScript forum
This post has been edited by pbl: 23 Sep, 2008 - 04:46 PM