JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

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 Dev Shed Forums Sponsor:
  #1  
Old August 3rd, 2001, 05:49 PM
mikeShank mikeShank is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: Philadelphia
Posts: 239 mikeShank User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 20 sec
Reputation Power: 13
Send a message via AIM to mikeShank
Generating Javascript

I don't know much about javascript, but I was able generate some javascript from some data retrieved from my database:

echo "document.write(\";
// echo my data...
echo "\");

this works fine.

but i'm having trouble generating a form this way:

echo "document.write(\";
echo "<FORM ACTION=\"http://www.mysite.com/process.php?\" METHOD=\"post\">";
//rest of form...
echo "</FORM>";
echo "\");

Is there a certian way you need to refer to form elements or form tags. I tried stripping echoed lines out one by one and it seems to be choking on the form tags.

Reply With Quote
  #2  
Old August 3rd, 2001, 05:58 PM
sLiPkNoT rUlEz sLiPkNoT rUlEz is offline
PHP Coder
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Ontario
Posts: 66 sLiPkNoT rUlEz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
Send a message via ICQ to sLiPkNoT rUlEz Send a message via AIM to sLiPkNoT rUlEz Send a message via Yahoo to sLiPkNoT rUlEz
echo can be broken across multiple lines...

echo "
<script>
<!--
document.write('<form action=\"http://www.mysite.com/process.php?\" method=\"post\"><!-- rest of form... --></form>');
// -->
</script>
";

document.write, on the other hand, is restricted to one line.
__________________
Click here and wait. It's a kewl effect, trust me.

Reply With Quote
  #3  
Old August 3rd, 2001, 06:10 PM
munkfish's Avatar
munkfish munkfish is offline
funky munky
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2001
Location: UK
Posts: 1,446 munkfish User rank is Corporal (100 - 500 Reputation Level)munkfish User rank is Corporal (100 - 500 Reputation Level)munkfish User rank is Corporal (100 - 500 Reputation Level)munkfish User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 18 h 45 m 36 sec
Reputation Power: 14
ahhh

so you could do:
PHP Code:
 $jsString="document.write(\""
        
."<FORM ACTION=\"http://www.mysite.com/process.php?\" METHOD=\"post\">"
        
."rest of form...".
        .
"</FORM>"

maybe and then echo or print the $jsString out:

PHP Code:
print($jsString); 


???

Reply With Quote
  #4  
Old August 3rd, 2001, 06:14 PM
mikeShank mikeShank is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: Philadelphia
Posts: 239 mikeShank User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 20 sec
Reputation Power: 13
Send a message via AIM to mikeShank
ok. but if i'm echoing my form between the document.write statement

echo "document.write(\";
// echo my form data...
echo "\");

isn't that generating one line.

Reply With Quote
  #5  
Old August 3rd, 2001, 07:27 PM
munkfish's Avatar
munkfish munkfish is offline
funky munky
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2001
Location: UK
Posts: 1,446 munkfish User rank is Corporal (100 - 500 Reputation Level)munkfish User rank is Corporal (100 - 500 Reputation Level)munkfish User rank is Corporal (100 - 500 Reputation Level)munkfish User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 18 h 45 m 36 sec
Reputation Power: 14
I don't echo at all really... always use print() so I'm not sure ;(

time for http://php.net/echo ...

mmm, reading between the lines (geddit, *groan*) the echo *construct* outputs newlines implicitly, whereas with the print() *function* newlines must be added explicitly.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Generating Javascript

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap