Affiliate Marketing
Forum Search

Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 27-03-08
Registered User
 
Join Date: Oct 2007
Posts: 428
Thanks: 0
Thanked 4 Times in 4 Posts
philhancox is an unknown quantity at this point
  Including javascript (or php) within text area

I currently have a snippet of text displayed on every page that automatically generates a link for them to use:

Code:
<p class="likeit">Link to this page: <textarea id="codearea" name="codearea" rows="6" cols="60">&lt;a href="<?php echo curPageURL();?>" target="_blank"&gt;<?php include ("title.js");?>&lt;/a&gt;</textarea></p>
The page URL is generated through PHP but the title is generated via Javascript. I've now put this text withing a
Code:
<textarea>
but the javascript breaks it, so instead of displaying the title like it should do, it simply displays
Code:
<script language="JavaScript">
document.write (document.title)
</script>
.

Is there a way of including the JS within the textarea so it actually works properly, or put it within a php statement, as the
Code:
<?php echo curPageURL();?>
seems to display correctly.

Cheers
__________________
Affiliate manager for TheRetailFactory | Discount Codes | Noob-in-training
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 27-03-08
Registered User
 
Join Date: Mar 2004
Location: Reading, UK
Posts: 301
Thanks: 0
Thanked 0 Times in 0 Posts
dmorison is an unknown quantity at this point
  Re: Including javascript (or php) within text area

Hi,

You won't be able to include JavaScript into the page within a TEXTAREA tag as all markup between those tags is displayed "asis", as you've discovered...

The first way I can think of to do this is to use JavaScript to update the text, substituting a placeholder (that you write in when generating the page) with document.title.

Try this:

Code:
<p class="likeit">Link to this page: <textarea id="codearea" name="codearea" rows="6" cols="60">&lt;a href="<?php echo curPageURL();?>" target="_blank"&gt;TITLE&lt;/a&gt;</textarea></p>
<script type='text/javascript'>
document.getElementById('codearea').innerHTML = document.getElementById('codearea').innerHTML.replace(/TITLE/,document.title);
</script>
Fingers crossed...!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 27-03-08
Registered User
 
Join Date: Oct 2007
Posts: 428
Thanks: 0
Thanked 4 Times in 4 Posts
philhancox is an unknown quantity at this point
  Re: Including javascript (or php) within text area

Haha, it doesn't matter whether it's here or the PT forums - you still answer extremely quickly and with a solution that works
Sir, you are a genius and a star. Thanks very much!
__________________
Affiliate manager for TheRetailFactory | Discount Codes | Noob-in-training
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 27-03-08
Registered User
 
Join Date: Mar 2004
Location: Reading, UK
Posts: 301
Thanks: 0
Thanked 0 Times in 0 Posts
dmorison is an unknown quantity at this point
  Re: Including javascript (or php) within text area

I'll do anything to satisfy my daily coding fix!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
New Vodafone deals on Mobile Rainbow! MobileRainbow Affiliate Future 0 27-04-07 02:52 PM
New Vodafone deals on Mobile Rainbow! MobileRainbow The Affiliate Marketing Lounge 0 27-04-07 02:43 PM
PHP/mysql formating problem with paragraphs Kandevil Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 2 25-01-07 09:48 PM
using php to print TD javascript code J Nas Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 2 17-03-05 03:01 PM
Including a PHP include within a PHP include ?? madstock Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 3 17-12-03 09:00 PM


Affiliate Marketing RSS Feeds - Contact Us - Affiliate Marketing - Archive - Privacy Statement - Top

Content Relevant URLs by vBSEO 3.2.0 RC7