Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old April 5th, 2004, 07:57 AM
wbutler wbutler is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 27 wbutler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Passing Form Code into a Textarea

I wrote a site for an organization here at school, and I put together a quick backend (PHP/mySQL. Surprise!) so that the non-technorati could edit the copy on the pages without help. One of the pages invites readers to respond to the articles on the site, so naturally it has some form code. The backend page yanks the code from the database and puts it between <textarea></textarea> tags so that the user can edit it.

The problem is that the browser can't properly distinguish between the code for the submit buttons on the page to be edited and the code for the submit buttons in the real, live form that actually the work. Here's what appears:

(Inside textarea)
HTML for text
HTML for form, up to code for form buttons

(After textarea)
Two form buttons that shouldn't have appeared
Two form buttons that should have


Is there any sort of clever way to make this work properly? I could hard-code the form into the page.php file and use an if statement to look for a flag, but that sort of defeats the purpose. I'm looking for something a bit more elegant.

The interesting part of the HTML is below.

<textarea name = "code" rows = 20 cols = 80>

<p>
Some nice text for people to read
</p>

<form method = POST action = "http://theurl.com">
<table cellpadding = 0 cellspacing = 0 align = "center">
<tr><td>Name:</td><td><input type = "text" size = 30 name = "sentby"></td></tr>
<tr><td>Email Address:</td><td><input type = "text" size = 30 name = "email"></td></tr>
<tr><td>Title of Article:</td><td><input type = "text" size = 50 name = "article"></td></tr>
<tr><td>Your Response:</td><td></td></tr>
<tr><td colspan = 2><textarea name = "text" cols = 49 rows = 10></textarea></td></tr>
</table>
<center>
<input type = "submit" value = "Send">&nbsp;&nbsp;&nbsp;<input type = "reset" value = "Reset">
</center>
</form>
<tr><td>
</textarea>

Reply With Quote
  #2  
Old April 5th, 2004, 08:00 AM
wbutler wbutler is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 27 wbutler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Passing Form Code into a Textarea

Whoops, sorry. The HTML above is what the php script generates for the user to see, and I left out some of the relevant bits. Let's try again:


<form method = "POST" action = "insertpage.php">
<table>
<tr><td>Page Title (For Admin Menu Only):</td><td><input type = "text" size = 63 name = "menuname" value = "Submissions"></td></tr>
</table>
Article Code:<br>
<textarea name = "code" rows = 20 cols = 80>

<p>
The copy for the end-users' page
</p>

<form method = POST action = "http://www.princeton.edu/cgi-bin/Princeton/formreply?mfmurray@princeton.edu+mmacdona@princeto n.edu">
<table cellpadding = 0 cellspacing = 0 align = "center">
<tr><td>Name:</td><td><input type = "text" size = 30 name = "sentby"></td></tr>
<tr><td>Email Address:</td><td><input type = "text" size = 30 name = "email"></td></tr>
<tr><td>Title of Article:</td><td><input type = "text" size = 50 name = "article"></td></tr>
<tr><td>Your Response:</td><td></td></tr>
<tr><td colspan = 2><textarea name = "text" cols = 49 rows = 10></textarea></td></tr>
</table>
<center>
<input type = "submit" value = "Send">&nbsp;&nbsp;&nbsp;<input type = "reset" value = "Reset">
</center>
</form>
<tr><td>
</textarea>
<p>
<input type = "hidden" name = "id" value = "2">
<input type = "submit" value = "Submit"> <input type = "submit" value = "Cancel">
</p>
</form>

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > Passing Form Code into a Textarea


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT