Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts

    Question CMS editing HTML in a textarea breaks code?!

    hi, I have some HTML to edit in my database, in my back end administration I have it in a textarea but when I go to edit it, it all messes up and lots of '/' area added, see below:

    Code:
    Site Design by: <a href=\\\\\\\"http://www.jbiddulph.com\\\\\\\" target=\\\\\\\"_blank\\\\\\\" title=\\\\\\\"John Biddulph - Web Development\\\\\\\">jbiddulph.com</a>
    php code
    Code:
    <p>
    								<label>Site Design by</label>
    								<textarea class="text-input small-input" name="SiteDesignby"><?php echo $row1['SiteDesignby'] ?></textarea>
    								</p>

    Can anyone help please?

  • #2
    Regular Coder
    Join Date
    Apr 2005
    Location
    Texas
    Posts
    448
    Thanks
    24
    Thanked 63 Times in 63 Posts
    js code
    Code:
    SiteDesignby.value = SiteDesignby.value.replace(/\\*."/g,'"');
    like that?
    Allwisend bin ich nicht, doch viel ist mir bewursst
    -Goethe

  • #3
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts
    thanks, I added
    Code:
    <script type="text/javascript">
    		SiteDesignby.value = SiteDesignby.value.replace(/\\*."/g,'"');
    	</script>
    to my page, nothing has changed?!

  • #4
    Regular Coder
    Join Date
    Apr 2005
    Location
    Texas
    Posts
    448
    Thanks
    24
    Thanked 63 Times in 63 Posts
    well it worked in the HTML only version in which I tested it, so maybe if you have a link to a sample page, maybe you missed something in your post...
    Allwisend bin ich nicht, doch viel ist mir bewursst
    -Goethe

  • #5
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts

    Exclamation

    here is my relative code:

    Code:
    <script type="text/javascript">
    		SiteDesignby.value = SiteDesignby.value.replace(/\\*."/g,'"');
    	</script>
    <p>
    								<label>Site Design by</label>
    								<textarea class="text-input small-input" name="SiteDesignby"><?php echo $row1['SiteDesignby'] ?></textarea>
    								</p>

  • #6
    Regular Coder
    Join Date
    Apr 2005
    Location
    Texas
    Posts
    448
    Thanks
    24
    Thanked 63 Times in 63 Posts
    1) That's server code... javascript executes on the client, so I actually need to see the output in the browser...
    2) You need to put the script I provided after the HTML, or register it with the onload event
    Allwisend bin ich nicht, doch viel ist mir bewursst
    -Goethe

  • #7
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts
    hi, I put it at the end of my html at the bottom of my page, still nothing changing?!
    hmm

    Code:
    <?php
    error_reporting(1);
    session_start();
    include_once("config.php");
    if (!isset($_SESSION['rsUser'])) {
    $msg = "Username and/or Password incorrect!";
    header('Location: index.php?msg='.$msg.'');
    }
    date_default_timezone_set('Europe/London');
    include ("getproperty_sql.php");
    ini_set('display_errors',1);
    error_reporting(E_ALL|E_STRICT);
    if (!isset($_REQUEST['msg']))
    {
    $_REQUEST['msg'] = "nothing";
    }
    
    $sql1=mysql_query("SELECT * FROM let_sitesettings WHERE SettingsID='1'");
    	$row1=mysql_fetch_array($sql1);
    
    $query2 = "SELECT * FROM let_categories";
    $result2 = mysql_query($query2);
    
    ?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    	<head>
    
    		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    
    		<title>TO LET Admin - Edit Settings</title>
    
    		<!--                       CSS                       -->
    
    		<!-- Reset Stylesheet -->
    		<link rel="stylesheet" href="resources/css/reset.css" type="text/css" media="screen" />
    
    		<!-- Main Stylesheet -->
    		<link rel="stylesheet" href="resources/css/style.css" type="text/css" media="screen" />
    		<link rel="stylesheet" href="resources/css/blue.css" type="text/css" media="screen" />
    		<!-- Invalid Stylesheet. This makes stuff look pretty. Remove it if you want the CSS completely valid -->
    		<link rel="stylesheet" href="resources/css/invalid.css" type="text/css" media="screen" />
    	<link rel="stylesheet" href="../css/colorpicker.css" type="text/css" />
        <script type="text/javascript" src="../js/jquery.js"></script>
    	<script type="text/javascript" src="../js/colorpicker.js"></script>
        <script type="text/javascript" src="../js/eye.js"></script>
        <script type="text/javascript" src="../js/utils.js"></script>
        <script type="text/javascript" src="../js/layout.js?ver=1.0.2"></script>
    		<!-- Colour Schemes
    
    		Default colour scheme is green. Uncomment prefered stylesheet to use it.
    
    		
    
    		<link rel="stylesheet" href="resources/css/red.css" type="text/css" media="screen" />
    
    		-->
    
    		<!-- Internet Explorer Fixes Stylesheet -->
    
    		<!--[if lte IE 7]>
    			<link rel="stylesheet" href="resources/css/ie.css" type="text/css" media="screen" />
    		<![endif]-->
    
    		<!--                       Javascripts                       -->
    
    		<!-- jQuery -->
    
    		<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
    
    		<!-- jQuery Configuration -->
    		<script type="text/javascript" src="resources/scripts/simpla.jquery.configuration.js"></script>
    
    		<!-- Facebox jQuery Plugin -->
    		<script type="text/javascript" src="resources/scripts/facebox.js"></script>
    
    		<!-- jQuery WYSIWYG Plugin -->
    		<script type="text/javascript" src="resources/scripts/jquery.wysiwyg.js"></script>
    
    		<!-- Internet Explorer .png-fix -->
    
    		<!--[if IE 6]>
    			<script type="text/javascript" src="resources/scripts/DD_belatedPNG_0.0.7a.js"></script>
    			<script type="text/javascript">
    				DD_belatedPNG.fix('.png_bg, img, li');
    			</script>
    		<![endif]-->
    
    	<script type="text/javascript">
    	      $(document).ready(function(){
    	            $("fieldset input[type=text]").focus(function(){
    	                $(this).parent().find(".input-notification").css("visibility", "visible");
    	            }).blur(function(){
    	                $(this).parent().find(".input-notification").css("visibility", "hidden");
    	            });
    	        });
    	</script>
    	<script type="text/javascript">
    	function confirmationpage(ID) {
    		var answer = confirm("Delete entry "+ID+" ?")
    		if (answer){
    			alert("Entry Deleted")
    			window.location = "delete-page.php?&PageID="+ID;
    		}
    		else{
    			alert("No action taken")
    		}
    	}
    	</script>
    	<script type="text/javascript">
    	function confirmationprop(ID) {
    		var answer = confirm("Delete entry "+ID+" ?")
    		if (answer){
    			alert("Entry Deleted")
    			window.location = "delete-property.php?&PropertyID="+ID;
    		}
    		else{
    			alert("No action taken")
    		}
    	}
    	</script>
    	<script src="http://cdn.jquerytools.org/1.2.6/jquery.tools.min.js"></script>
    	<script type="text/javascript">
    		SiteDesignby.value = SiteDesignby.value.replace(/\\*."/g,'"');
    	</script>
    	</head>
    
    	<body><div id="body-wrapper"> <!-- Wrapper for the radial gradient background -->
    
    		<?
    $menuitem=6;
    $submenuitem=1;
    include("menu.php");
    ?>
    
    		<div id="main-content"> <!-- Main Content Section with everything -->
    
    			<noscript> <!-- Show a notification if the user has disabled javascript -->
    				<div class="notification error png_bg">
    					<div>
    						Javascript is disabled or is not supported by your browser. Please <a href="http://browsehappy.com/" title="Upgrade to a better browser">upgrade</a> your browser or <a href="http://www.google.com/support/bin/answer.py?answer=23852" title="Enable Javascript in your browser">enable</a> Javascript to navigate the interface properly.
    					</div>
    				</div>
    			</noscript>
    
    			<!-- Page Head -->
    			<?php include_once("welcome.php");?>
    
    			<div class="clear"></div> <!-- End .clear -->
    
    			<div class="content-box"><!-- Start Content Box -->
    
    				<div class="content-box-header">
    
    					<h3>Edit Settings</h3>
    
    					<div class="clear"></div>
    
    				</div> <!-- End .content-box-header -->
    
    				<div class="content-box-content">
    					
    					<div class="tab-content default-tab" id="tab1">
    					<?php if($_REQUEST['msg'] == "Settings edited"){?>
    						<div class="notification success png_bg">
    							<a href="#" class="close"><img src="resources/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
    							<div>
    								Settings edited!
    							</div>
    						</div>
    						<?php } ?>
    						<form action="edit-settings-script.php?SettingsID=<?php echo $row1['SettingsID']; ?>" method="post" enctype="multipart/form-data">
    
    							<fieldset> <!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->
    								<p>
    								<label>Site Name</label>
    								<input class="text-input small-input" name="SiteName" type="text" value="<?php echo $row1['SiteSlogan'] ?>" />
    								</p>
    								<p>
    								<label>Site Slogan</label>
    								<input class="text-input small-input" name="SiteSlogan" type="text" value="<?php echo $row1['SiteSlogan'] ?>" />
    								</p>
    								<p>
    								<label>Site Email</label>
    								<input class="text-input small-input" name="SiteEmail" type="text" value="<?php echo $row1['SiteEmail'] ?>" />
    								</p>
    								<p>
    								<label>Site Telephone</label>
    								<input class="text-input small-input" name="SiteTelephone" type="text" value="<?php echo $row1['SiteTelephone'] ?>" />
    								</p>
    								<p>
    								<label>Site Copyright</label>
    								<input class="text-input small-input" name="SiteCopyright" type="text" value="<?php echo $row1['SiteCopyright'] ?>" />
    								</p>
    								<p>
    								<label>Site Design by</label>
    								<textarea class="text-input small-input" name="SiteDesignby"><?php echo htmlspecialchars_decode($row1['SiteDesignby']) ?></textarea>
    								</p>
    								<p>
    								<label>Site Analytics</label>
    								<textarea class="text-input small-input" name="SiteAnalytics"><?php echo $row1['SiteAnalytics'] ?></textarea>
    								</p>
    								<p>
    								<label>Site Social</label>
    								<textarea class="text-input small-input" name="SiteSocial"><?php echo $row1['SiteSocial'] ?></textarea>
    								</p>
    								<p>
    								<label>Social Status</label>
    									<input type="radio" name="SiteSocialStatus" <? if($row1['SiteSocialStatus']=='0'){echo 'checked';}?> value="0" /> OFF<br />
    									<input type="radio" name="SiteSocialStatus" <? if($row1['SiteSocialStatus']=='1'){echo 'checked';}?> value="1" /> ON
    								</p>
    								<p>
    									<input class="button" type="submit" value="Edit Settings" />
    								</p>
    								
    
    							</fieldset>
    
    							<div class="clear"></div><!-- End .clear -->
    
    						</form>
    				
    					</div>
    
    				</div> <!-- End .content-box-content -->
    
    
    			</div> <!-- End .content-box -->
    
    			<?php include_once("footer.php");?><!-- End #footer -->
    
    		</div> <!-- End #main-content -->
    
    	</div>
    </body>
    </html>
    <script type="text/javascript">
    	SiteDesignby.value = SiteDesignby.value.replace(/\\*."/g,'"');
    </script>

  • #8
    Regular Coder
    Join Date
    Apr 2005
    Location
    Texas
    Posts
    448
    Thanks
    24
    Thanked 63 Times in 63 Posts
    Once again, that is the input(serverside code), I need the OUTPUT(clientside code) in the browser in order to apply JavaScript.

    From your post I would infer that your error is a php problem. But since I don't know php, and you posted in a JavaScript forum I gave you a JavaScript solution.
    If the browser has the html link inside a text area, you need to change the value of the textarea. This can be accomplished with the form, or by getElementById. Your document has neither an id value or form name value, and that is why it didn't work.
    try the following
    Code:
    <p>
    <form name="myForm"> <!-- note the form name -->
    	<label>Site Design by</label>
    	<textarea class="text-input small-input" name="SiteDesignby">site...<a href=\\\\\\\"http://www.jbiddulph.com\\\\\\\" target=\\\\\\\"_blank\\\\\\\" title=\\\\\\\"John Biddulph - Web Development\\\\\\\">jbiddulph.com</a><!-- BTW this is what clienside code would look like --></textarea>
    </form>
    </p>
    <script>
    myForm.SiteDesignby.value = myForm.SiteDesignby.value.replace(/\\*."/g,'"');
    </script>
    IMO fixing a php problem with JavaScript isn't necessarily the best solution
    Allwisend bin ich nicht, doch viel ist mir bewursst
    -Goethe

  • #9
    New Coder
    Join Date
    Oct 2011
    Location
    New york
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Thumbs up

    You would need to perform an ajax request to retrieve the js file from the server, and the callback would dump the contents into the textarea. If you're going to let users enter JavaScript codes into your CMS, be sure you're up to speed on cross-site scripting (XSS).

    Edit: JavaScript is just a language. There are plenty of server side implementations. In the CMS market, for example LiveLink CMS uses it as their server side language. Also recently you might of heard of node.js?

    Good luck
    Jackie
    Last edited by JackieBolinsky; 02-23-2012 at 06:14 AM. Reason: typing error and additional info

  • #10
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts
    last relevant part of my HTML

    Code:
    								<p>
    								<label>Site Design by</label>
    								<textarea class="text-input small-input" name="SiteDesignby">Site Design by: <a href=\\\\\\\"http://www.jbiddulph.com\\\\\\\" target=\\\\\\\"_blank\\\\\\\" title=\\\\\\\"John Biddulph - Web Development\\\\\\\">jbiddulph.com</a></textarea>
    								</p>
    								<p>
    								<label>Site Analytics</label>
    								<textarea class="text-input small-input" name="SiteAnalytics"></textarea>
    
    								</p>
    								<p>
    								<label>Site Social</label>
    								<textarea class="text-input small-input" name="SiteSocial"><div class=\\\\\\\"social\\\\\\\">		
    				<span class=\\\\\\\'st_sharethis_hcount\\\\\\\' displayText=\\\\\\\'ShareThis\\\\\\\'></span>
    				<span class=\\\\\\\'st_google_hcount\\\\\\\' displayText=\\\\\\\'Google\\\\\\\'></span>
    				<span class=\\\\\\\'st_facebook_hcount\\\\\\\' displayText=\\\\\\\'Facebook\\\\\\\'></span>
    				<span class=\\\\\\\'st_twitter_hcount\\\\\\\' displayText=\\\\\\\'Tweet\\\\\\\'></span>
    				<span class=\\\\\\\'st_linkedin_hcount\\\\\\\' displayText=\\\\\\\'LinkedIn\\\\\\\'></span>
    				<span class=\\\\\\\'st_email_hcount\\\\\\\' displayText=\\\\\\\'Email\\\\\\\'></span>
    				<span class=\\\\\\\'st_fblike_hcount\\\\\\\' displayText=\\\\\\\'Facebook Like\\\\\\\'></span>
    			</div></textarea>
    								</p>
    								<p>
    								<label>Social Status</label>
    
    									<input type="radio" name="SiteSocialStatus" checked value="0" /> OFF<br />
    									<input type="radio" name="SiteSocialStatus"  value="1" /> ON
    								</p>
    								<p>
    									<input class="button" type="submit" value="Edit Settings" />
    								</p>
    								
    
    							</fieldset>
    
    							<div class="clear"></div><!-- End .clear -->
    
    						</form>
    				
    					</div>
    
    				</div> <!-- End .content-box-content -->
    
    
    			</div> <!-- End .content-box -->
    
    			<div id="footer">
    	<small>
    			Copyright &copy; TO LET 2012 | <a href="#">Top</a>
    	</small>
    </div><!-- End #footer -->
    
    		</div> <!-- End #main-content -->
    
    	</div>
    </body>
    </html>
    <script type="text/javascript">
    	SiteDesignby.value = SiteDesignby.value.replace(/\\*."/g,'"');
    </script>

  • #11
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts
    ok, all seems to be sort of ok, I sorted out the SiteDesignby but now I have a problem with SiteSocial, here is my SQL:

    Code:
    UPDATE let_sitesettings SET SiteName='Letting agents with property for rent',SiteSlogan='Letting agents with property for rent',SiteEmail='info@tolet.co.uk',SiteTelephone='01903 530000',SiteCopyright='Copyright © 2012 TO LET',SiteDesignby='Site Design by: jbiddulph.com',SiteAnalytics='',SiteSocial='
    \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    ',SiteSocialStatus='0' WHERE SettingsID = '1'

  • #12
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts
    hmm no, still not working?! isn't there a php function i can just wrap around my php?!

  • #13
    Regular Coder
    Join Date
    Apr 2005
    Location
    Texas
    Posts
    448
    Thanks
    24
    Thanked 63 Times in 63 Posts
    thanks for the browser HTML, I see now that you have multiple things to test for that were not apparent before. so the js solution would be

    Code:
    allTextInputs = document.getElementsByTagName('textarea');	// Create an array of all our problem textareas
    
    for (var i = 0 ; i<allTextInputs.length ; ++i) {	// Iterate through all the textarea elements
    
        allTextInputs[i].value = allTextInputs[i].value.replace(/\\*."/g,'"').replace(/\\*.'/g,'"');	// Replace unwanted backslashes, Not sure if this is the best RegEx, but they are not a specialty of mine...
    
    };
    // tested in IE9 - chrome - FF against the supplied HTML.
    You implied that maybe you already moved on to another issue... just thought I'd help where I can. Good Luck.
    Allwisend bin ich nicht, doch viel ist mir bewursst
    -Goethe


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •