Current location: Hot Scripts Forums » Programming Languages » PHP » populate textarea using dropdown list


populate textarea using dropdown list

Reply
  #21 (permalink)  
Old 12-17-09, 02:35 PM
beazleybub beazleybub is offline
Newbie Coder
 
Join Date: Oct 2009
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
There is a bug when saving data to the data6.php file. I'm not sure if this is tinymce related.
For some reason when i add a text string to the file from within the editor and click the save icon it saves the content ok but when the page refreshes it cuts off some of the content from within the editor. If this makes any sense. If I refresh the page it comes back.

Thanks to the both of you for all your effort and time.
I certainly wish a pleasant holiday season to you and your family.

Last edited by beazleybub; 12-17-09 at 02:48 PM.
Reply With Quote
  #22 (permalink)  
Old 12-17-09, 10:14 PM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Quote:
Originally Posted by beazleybub View Post
There is a bug when saving data to the data6.php file. I'm not sure if this is tinymce related.
For some reason when i add a text string to the file from within the editor and click the save icon it saves the content ok but when the page refreshes it cuts off some of the content from within the editor. If this makes any sense. If I refresh the page it comes back.

Thanks to the both of you for all your effort and time.
I certainly wish a pleasant holiday season to you and your family.
I think it has something to do with the amount of time it takes to save the file.
So, I added another array element to the $dataFiles array at the end, called "end_of_array".
This "end_of_array" element must be at the end of the array.
It causes the program to perform additional condition statements, giving the file enough time to be saved.
PHP Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>editor</title>
<!-- TinyMCE -->
   <script language="javascript" type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script>
   <script type="text/javascript">
    tinyMCE.init({
        // General options
        mode : "textareas",
        theme : "advanced",
        plugins : "ibrowser,safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount",

        // Theme options
        theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
        theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,|,image,ibrowser,|,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
        theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
        theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,ibrowser",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : true,

        // Example content CSS (should be your site CSS)
        content_css : "css/content.css",

        // Drop lists for link/image/media/template dialogs
        template_external_list_url : "lists/template_list.js",
        external_link_list_url : "lists/link_list.js",
        external_image_list_url : "lists/image_list.js",
        media_external_list_url : "lists/media_list.js",

        // Replace values for the template plugin
        template_replace_values : {
            username : "Some User",
            staffid : "991234"
        }
    });
</script>
<!-- /TinyMCE -->
</head>
<body>
<?php
$dataFiles
=array("instructions.php","data1.php","data2.php","data3.php","data4.php","data5.php","data6.php","end_of_array");
for(
$i=0;$i<count($dataFiles)-1;$i++)
{
 if(!
file_exists($dataFiles[$i]))
 {
  
$fp=fopen($dataFiles[$i],"w");
  
fwrite($fp," ");
  
fclose($fp);
  }
 else
 {
  if(
filesize($dataFiles[$i])<=0)
  {
   
$fp=fopen($dataFiles[$i],"a");
   
fwrite($fp," ");
   
fclose($fp);
   }
  }
 }
$file=empty($_POST["source"])?" ":$_POST["source"];
if(!empty(
$_POST["current_file"]))
{
 
$data=empty($_POST['data'])?" ":$_POST['data'];
 
$file=$_POST["current_file"];
 
$fh=fopen($file,"w");
 
fwrite($fh,$data);
 
fclose($fh);
 }
if(
file_exists($file))
{
 
$fh=fopen($file,'r');
 
$data=stripslashes(fread($fh,filesize($file)));
 
fclose($fh);
 }
?>
<form action="#" method="post">
 <textarea name="data" cols="100" rows="10"><?php echo $data?></textarea>
 <input type="hidden" name="current_file" value="<?php echo $file?>">
</form>
<form name="view_form" action="#" method="POST">
 <select name="source" onchange="view_form.submit();">
  <option value="">Select a source file to view...</option>
  <?php
  
for($i=0;$i<count($dataFiles);$i++)
  {
   
$selected="";
   if(
$dataFiles[$i]!="end_of_array")
   {
    if(
$file==$dataFiles[$i]){$selected="selected";}
    echo 
"<option value='$dataFiles[$i]$selected>$dataFiles[$i]</option>";
    }
   }
  
?>
 </select>
</form>
</body>
</html>
And a happy holiday to you and yours.
Wishing you the very best.
__________________
Jerry Broughton

Last edited by job0107; 12-18-09 at 12:08 AM.
Reply With Quote
  #23 (permalink)  
Old 01-18-10, 12:19 PM
beazleybub beazleybub is offline
Newbie Coder
 
Join Date: Oct 2009
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
Hi job0107,

I added an image upload ability to the editor but I'm getting some sort of problem.
When saving the file the image links end up looking like this in the output file.

<IMG src=\"http://127.0.0.1/UserFiles/Image/!cid_pic041907_2.jpg\" width=179 height=94 mce_src=\"../UserFiles/Image/!cid_pic041907_2.jpg\">

At first I thought it had something to do with the tinyfck image manager i am using to upload images but i also tried another image manager called ibrowser and I get the same kinds of links.

Do you think you might be able to help me on this please.

Thank you, Robert
Reply With Quote
  #24 (permalink)  
Old 01-18-10, 12:58 PM
beazleybub beazleybub is offline
Newbie Coder
 
Join Date: Oct 2009
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
Strange,

When I upload it to the server everything works just fine.
But when I test it using xampp on my local machine it goofs.

The weird thing is that it was working on localhost before then it just started malfunctioning.

Do you think my php settings have been corrupted?
Reply With Quote
  #25 (permalink)  
Old 01-18-10, 01:15 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,515
Thanks: 20
Thanked 109 Times in 106 Posts
Probably not corrupted, just different.

Might also be a path issue, or a PHP version issue.
Reply With Quote
  #26 (permalink)  
Old 01-18-10, 01:17 PM
beazleybub beazleybub is offline
Newbie Coder
 
Join Date: Oct 2009
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
Reinstalling xampp fixed the issue. I have no idea what caused it but it's fine now.


Last edited by beazleybub; 01-18-10 at 01:44 PM.
Reply With Quote
  #27 (permalink)  
Old 01-20-10, 03:07 AM
beazleybub beazleybub is offline
Newbie Coder
 
Join Date: Oct 2009
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
How would I go about getting the instructions.php to load into the textarea on page load?

Thanks

Last edited by beazleybub; 01-20-10 at 03:24 AM.
Reply With Quote
  #28 (permalink)  
Old 02-05-10, 06:28 PM
beazleybub beazleybub is offline
Newbie Coder
 
Join Date: Oct 2009
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
Please don't give up on me. I learn by example.
Reply With Quote
  #29 (permalink)  
Old 02-10-10, 07:42 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Quote:
Originally Posted by beazleybub View Post
How would I go about getting the instructions.php to load into the textarea on page load?

Thanks
You see this line here:
PHP Code:

$file=empty($_POST["source"])?" ":$_POST["source"]; 

This part would be the default file:
PHP Code:

?" " 

So to get instructions.php to be the default file on initial page load, you do it like this:
PHP Code:

$file=empty($_POST["source"])?"instructions.php":$_POST["source"]; 

__________________
Jerry Broughton
Reply With Quote
The Following User Says Thank You to job0107 For This Useful Post:
beazleybub (02-10-10)
  #30 (permalink)  
Old 02-10-10, 10:53 AM
beazleybub beazleybub is offline
Newbie Coder
 
Join Date: Oct 2009
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
Special thanks to all of you who took the time to help me out. I have been juggling so much I haven't had time to study like I'd like to. Just to let you guys know, soon I will be taking a full fledged PHP course and learn the way I should so I can do things on my own

Thanks again.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
refreshing dropdown list when selecting another drop down list theighost Script Requests 3 08-14-08 08:30 AM
refreshing dropdown list when selecting another drop down list theighost PHP 1 08-13-08 10:10 AM
Can I populate a dropdown list???? zorrox02 JavaScript 4 10-01-04 04:03 AM


All times are GMT -5. The time now is 08:05 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.