Jump to content

Need Help with _POST w/ Multiple Rich Text Editors


Joe689

Recommended Posts

<?

 

include('admin_header.php');

require_once('../classes/property.class.php');

 

if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) {

       

    $id = $_GET['id'];

   

    $property = new Property($id);

   

    // Submitted form, Save the property

    if($_POST['submit']) {

 

      $property->set_property_notes(stripslashes($_POST['notes']));

        if (empty($property->error) && $property->save()) {

            $message =  $property->get_property_long_name() . " successfully edited.";

        } else {

            $message = display_error($property->error);

        }

    }

} else {

    echo "There was an error in your request.";

}

 

 

?>

 

<h3>View Properties</h3>

 

<table id="content">

<tr>

  <th align="center"><a href="?order=property_long_name" title="Order by Property Name">Property Name</a></th>

  <th align="center"><a href="?order=property_city" title="Order by Property City">City</th>

  <th align="center"><a href="?order=state_name" title="Order by Property State">State</th>

  <th align="center">Special</th>

  <th align="center">Actions</th>

</tr>

 

 

<?

if ($list_property) {

 

  $class = true;

  while ($property = &$list_property->next()) {

?>

 

 

<form name="RTE" method="post"  action="<?php echo $_SERVER['PHP_SELF']; ?>?id=<? echo $property->get_property_id() ?>" onsubmit="return submitForm();">

<script language="JavaScript" type="text/javascript" src="/scripts/richtext_compressed.js"></script>

 

 

<script>

function submitForm() {

updateRTEs();

return true;

}

</script>

 

 

<script>

initRTE("/scripts/images/", "/scripts/", "", false);

</script>

    <script>  

  var rte1= new richTextEditor('notes');

    rte1.html = '<?= rteSafe($property->get_property_notes()) ?>';

        rte1.build();

        </script>

</script>

</td>

<td>

 

<input type="hidden" name="id" value="<?= $property->get_property_id() ?>">

            <input type="submit" name="submit" value="Update">

 

        </form> </td>

    </tr>

 

 

<?

$class = ! $class;

}

} else {

 

?>

 

<tr>

  <td align="center"><br>No Properties Available.</td>

</tr>

 

<? } ?>

 

</table>

 

P.S.  I have taken out much of code that isn't necessary

 

 

Basically, the website displays all the property locations and displays their notes.  I want the user to be able to change these notes using the rich text editor, and when submitted update the current notes.  This is what I know:  In order for the multiple Rich Text Editor's to behave properly, they must have a unique name.  They can't all be named 'notes' although the var name can be the same.  What is the best way, to dynamically change the name of the Rich Text Editor every time one is created during the while loop and have the _Post[varname] to match to the correct Rich Text Editor.  I do know, that if I have only one Rich Text Editor, meaning no while loop creating multiple, this script works perfectly

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.