Re: [PHP] How can I echo a javascript var in an email subject line? Possible? (Yes!)RESOLVED
Thanks Terion Happy Freecycling Free the List !! www.freecycle.org Over Moderation of Freecycle List Prevents Post Timeliness. Report Moderator Abuse Here: http://www.freecycle.org/faq/faq/contact-info Or Email Your Complaint to: f...@freecycle.org or i...@freecycle.org Twitter? http://twitter.com/terionmiller Facebook: a href=http://www.facebook.com/people/Terion-Miller/1542024891; title=Terion Miller's Facebook profile target=_TOPimg src= http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0 alt=Terion Miller's Facebook profile/a On Wed, Apr 8, 2009 at 7:43 PM, Raymond Irving xwis...@yahoo.com wrote: For me its very easy to pass php values to the client: echo _var($value,'name'); But the best part is taking control of what your client sees from the server-side: C('#info')-show(); // now you see it ... C('#info')-hide(); // now you don't! Take control and start building powerful web apps with Raxan PDI - http://raxanpdi.com __ Raymond Irving Create Rich Ajax/PHP Web Apps today! Raxan PDI - http://raxanpdi --- On Wed, 4/8/09, Michael A. Peters mpet...@mac.com wrote: From: Michael A. Peters mpet...@mac.com Subject: Re: [PHP] How can I echo a javascript var in an email subject line? Possible? To: Terion Miller webdev.ter...@gmail.com Cc: PHP General php-general@lists.php.net Date: Wednesday, April 8, 2009, 2:34 PM Terion Miller wrote: On Wed, Apr 8, 2009 at 12:50 PM, Michael A. Peters mpet...@mac.com mailto:mpet...@mac.com wrote: Terion Miller wrote: javascript is client side. php is server side. To use something client side in a server side script, the web page has to send it to the server from the client. The best way to do what you want to do is probably to do the work count server side, but if you really want to use what javascript produced you can create a hidden input with a specified id, and use dhtml via javascript to modify the input and insert the value into the value field of the hidden input. Then it will get sent to the server when the user hits the post button. However, since you should be validating any user input server side, you'll need to validate that the variable is accurate - might as well just do the count with php server side. Thanks Michael I was kind of moving in the right direction as far as the hidden input goes, going to have to google on how to do it with the dhtml and all like you suggested. Look at the various DOM functions - IE for input type=hidden name=wordcount id=hiddenStudd value= you coud do in your js: var myHidden = document.getElementById('hiddenStuff'); myHidden.setAttribute('value',$yourvalue); Thought I would go ahead and post a bit more on this, so here is my wordcount little function on the textarea of the form: textarea name=Comments cols=55 rows=5 wrap=hard onKeyDown=wordCounter(this.form.Comments,this.form.remLen, 300); onKeyUp=wordCounter(this.form.Comments,this.form.remLen, 300);?php if (isset($_SESSION['Comments'])) {echo $_SESSION['Comments'];} ?/textareabrLetters to the Editor are limited to 300 words or less.brWords remaining: input type=box readonly name=remLen size=3 value=300 So I was thinking I should be able to pass that again to the next page which is the emailform.php page that is taking all the id= and printing them to an email should be able to reuse that function right? input type=hidden id=words value= onSubmit=return wordCounter(this.form.Comments,this.form.remLen); or do I need to define the variable? think I'm starting to confuse myself lol You don't want the onSubmit in the the hidden input. I'm not a javascript guru - but I believe you can have the form onSubmit do the word count and insert it into the input field before the actual submit happens, I've never tried having an onsubmit function alter a value field though. I would change the textarea to have an id=Comments field and the remLen input to have an id=remLen field to make it easy to find via getElementById (as id attributes have to be unique), count the words and set them to a variable that then gets put into the hidden input before whatever function you run on the submit type onSubmit returns true. not tested - but something like this: function countTheWords() { var comment = $document.getElementById('Comments'); var remLen = $document.getElementById('remLen').value; var count = wordCounter
Re: [PHP] How can I echo a javascript var in an email subject line? Possible?
At 1:00 PM -0500 4/8/09, Terion Miller wrote: Thought I would go ahead and post a bit more on this, so here is my wordcount little function on the textarea of the form: -snip- or do I need to define the variable? think I'm starting to confuse myself lol The reason why you are starting to confuse yourself is that you are still considering doing some part of this by including javascript in the solution -- there is NO need. Just receive what the user submits and process it server-side before mailing -- pure and simple. That way not only can you clean the submission, but you can count the words and put that count in the subject line like you wanted. This really a simple problem. You are complicating it by including javascript. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How can I echo a javascript var in an email subject line? Possible?
Terion Miller wrote: I have a php form, that uses a javascript word counter to make sure submissions are a certain number of words, I have now been tasked with taking that word count and having it pass in the email that gets sent when someone submits a form ..in the subject line. Here is the code I'm using so far. Is it possible to just echo a javascript variable on a page like you can a php var? javascript is client side. php is server side. To use something client side in a server side script, the web page has to send it to the server from the client. The best way to do what you want to do is probably to do the work count server side, but if you really want to use what javascript produced you can create a hidden input with a specified id, and use dhtml via javascript to modify the input and insert the value into the value field of the hidden input. Then it will get sent to the server when the user hits the post button. However, since you should be validating any user input server side, you'll need to validate that the variable is accurate - might as well just do the count with php server side. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How can I echo a javascript var in an email subject line? Possible?
javascript is client side. php is server side. To use something client side in a server side script, the web page has to send it to the server from the client. The best way to do what you want to do is probably to do the work count server side, but if you really want to use what javascript produced you can create a hidden input with a specified id, and use dhtml via javascript to modify the input and insert the value into the value field of the hidden input. Then it will get sent to the server when the user hits the post button. However, since you should be validating any user input server side, you'll need to validate that the variable is accurate - might as well just do the count with php server side. Thanks Michael I was kind of moving in the right direction as far as the hidden input goes, going to have to google on how to do it with the dhtml and all like you suggested. Thanks
Re: [PHP] How can I echo a javascript var in an email subject line? Possible?
Terion Miller wrote: javascript is client side. php is server side. To use something client side in a server side script, the web page has to send it to the server from the client. The best way to do what you want to do is probably to do the work count server side, but if you really want to use what javascript produced you can create a hidden input with a specified id, and use dhtml via javascript to modify the input and insert the value into the value field of the hidden input. Then it will get sent to the server when the user hits the post button. However, since you should be validating any user input server side, you'll need to validate that the variable is accurate - might as well just do the count with php server side. Thanks Michael I was kind of moving in the right direction as far as the hidden input goes, going to have to google on how to do it with the dhtml and all like you suggested. Look at the various DOM functions - IE for input type=hidden name=wordcount id=hiddenStudd value= you coud do in your js: var myHidden = document.getElementById('hiddenStuff'); myHidden.setAttribute('value',$yourvalue); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How can I echo a javascript var in an email subject line? Possible?
On Wed, Apr 8, 2009 at 12:50 PM, Michael A. Peters mpet...@mac.com wrote: Terion Miller wrote: javascript is client side. php is server side. To use something client side in a server side script, the web page has to send it to the server from the client. The best way to do what you want to do is probably to do the work count server side, but if you really want to use what javascript produced you can create a hidden input with a specified id, and use dhtml via javascript to modify the input and insert the value into the value field of the hidden input. Then it will get sent to the server when the user hits the post button. However, since you should be validating any user input server side, you'll need to validate that the variable is accurate - might as well just do the count with php server side. Thanks Michael I was kind of moving in the right direction as far as the hidden input goes, going to have to google on how to do it with the dhtml and all like you suggested. Look at the various DOM functions - IE for input type=hidden name=wordcount id=hiddenStudd value= you coud do in your js: var myHidden = document.getElementById('hiddenStuff'); myHidden.setAttribute('value',$yourvalue); Thought I would go ahead and post a bit more on this, so here is my wordcount little function on the textarea of the form: textarea name=Comments cols=55 rows=5 wrap=hard onKeyDown=wordCounter(this.form.Comments,this.form.remLen, 300); onKeyUp=wordCounter(this.form.Comments,this.form.remLen, 300);?php if (isset($_SESSION['Comments'])) {echo $_SESSION['Comments'];} ?/textareabrLetters to the Editor are limited to 300 words or less.brWords remaining: input type=box readonly name=remLen size=3 value=300 So I was thinking I should be able to pass that again to the next page which is the emailform.php page that is taking all the id= and printing them to an email should be able to reuse that function right? input type=hidden id=words value= onSubmit=return wordCounter(this.form.Comments,this.form.remLen); or do I need to define the variable? think I'm starting to confuse myself lol
Re: [PHP] How can I echo a javascript var in an email subject line? Possible?
Terion Miller wrote: On Wed, Apr 8, 2009 at 12:50 PM, Michael A. Peters mpet...@mac.com mailto:mpet...@mac.com wrote: Terion Miller wrote: javascript is client side. php is server side. To use something client side in a server side script, the web page has to send it to the server from the client. The best way to do what you want to do is probably to do the work count server side, but if you really want to use what javascript produced you can create a hidden input with a specified id, and use dhtml via javascript to modify the input and insert the value into the value field of the hidden input. Then it will get sent to the server when the user hits the post button. However, since you should be validating any user input server side, you'll need to validate that the variable is accurate - might as well just do the count with php server side. Thanks Michael I was kind of moving in the right direction as far as the hidden input goes, going to have to google on how to do it with the dhtml and all like you suggested. Look at the various DOM functions - IE for input type=hidden name=wordcount id=hiddenStudd value= you coud do in your js: var myHidden = document.getElementById('hiddenStuff'); myHidden.setAttribute('value',$yourvalue); Thought I would go ahead and post a bit more on this, so here is my wordcount little function on the textarea of the form: textarea name=Comments cols=55 rows=5 wrap=hard onKeyDown=wordCounter(this.form.Comments,this.form.remLen, 300); onKeyUp=wordCounter(this.form.Comments,this.form.remLen, 300);?php if (isset($_SESSION['Comments'])) {echo $_SESSION['Comments'];} ?/textareabrLetters to the Editor are limited to 300 words or less.brWords remaining: input type=box readonly name=remLen size=3 value=300 So I was thinking I should be able to pass that again to the next page which is the emailform.php page that is taking all the id= and printing them to an email should be able to reuse that function right? input type=hidden id=words value= onSubmit=return wordCounter(this.form.Comments,this.form.remLen); or do I need to define the variable? think I'm starting to confuse myself lol You don't want the onSubmit in the the hidden input. I'm not a javascript guru - but I believe you can have the form onSubmit do the word count and insert it into the input field before the actual submit happens, I've never tried having an onsubmit function alter a value field though. I would change the textarea to have an id=Comments field and the remLen input to have an id=remLen field to make it easy to find via getElementById (as id attributes have to be unique), count the words and set them to a variable that then gets put into the hidden input before whatever function you run on the submit type onSubmit returns true. not tested - but something like this: function countTheWords() { var comment = $document.getElementById('Comments'); var remLen = $document.getElementById('remLen').value; var count = wordCounter($comment,$remLen); var myHidden = document.getElementById('words'); myHidden.setAttribute('value',$count); } Then in whatever function you run in the form onSumbit have it run the countTheWords() function before it exits. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How can I echo a javascript var in an email subject line? Possible? (Yes!)
For me its very easy to pass php values to the client: echo _var($value,'name'); But the best part is taking control of what your client sees from the server-side: C('#info')-show(); // now you see it ... C('#info')-hide(); // now you don't! Take control and start building powerful web apps with Raxan PDI - http://raxanpdi.com __ Raymond Irving Create Rich Ajax/PHP Web Apps today! Raxan PDI - http://raxanpdi --- On Wed, 4/8/09, Michael A. Peters mpet...@mac.com wrote: From: Michael A. Peters mpet...@mac.com Subject: Re: [PHP] How can I echo a javascript var in an email subject line? Possible? To: Terion Miller webdev.ter...@gmail.com Cc: PHP General php-general@lists.php.net Date: Wednesday, April 8, 2009, 2:34 PM Terion Miller wrote: On Wed, Apr 8, 2009 at 12:50 PM, Michael A. Peters mpet...@mac.com mailto:mpet...@mac.com wrote: Terion Miller wrote: javascript is client side. php is server side. To use something client side in a server side script, the web page has to send it to the server from the client. The best way to do what you want to do is probably to do the work count server side, but if you really want to use what javascript produced you can create a hidden input with a specified id, and use dhtml via javascript to modify the input and insert the value into the value field of the hidden input. Then it will get sent to the server when the user hits the post button. However, since you should be validating any user input server side, you'll need to validate that the variable is accurate - might as well just do the count with php server side. Thanks Michael I was kind of moving in the right direction as far as the hidden input goes, going to have to google on how to do it with the dhtml and all like you suggested. Look at the various DOM functions - IE for input type=hidden name=wordcount id=hiddenStudd value= you coud do in your js: var myHidden = document.getElementById('hiddenStuff'); myHidden.setAttribute('value',$yourvalue); Thought I would go ahead and post a bit more on this, so here is my wordcount little function on the textarea of the form: textarea name=Comments cols=55 rows=5 wrap=hard onKeyDown=wordCounter(this.form.Comments,this.form.remLen, 300); onKeyUp=wordCounter(this.form.Comments,this.form.remLen, 300);?php if (isset($_SESSION['Comments'])) {echo $_SESSION['Comments'];} ?/textareabrLetters to the Editor are limited to 300 words or less.brWords remaining: input type=box readonly name=remLen size=3 value=300 So I was thinking I should be able to pass that again to the next page which is the emailform.php page that is taking all the id= and printing them to an email should be able to reuse that function right? input type=hidden id=words value= onSubmit=return wordCounter(this.form.Comments,this.form.remLen); or do I need to define the variable? think I'm starting to confuse myself lol You don't want the onSubmit in the the hidden input. I'm not a javascript guru - but I believe you can have the form onSubmit do the word count and insert it into the input field before the actual submit happens, I've never tried having an onsubmit function alter a value field though. I would change the textarea to have an id=Comments field and the remLen input to have an id=remLen field to make it easy to find via getElementById (as id attributes have to be unique), count the words and set them to a variable that then gets put into the hidden input before whatever function you run on the submit type onSubmit returns true. not tested - but something like this: function countTheWords() { var comment = $document.getElementById('Comments'); var remLen = $document.getElementById('remLen').value; var count = wordCounter($comment,$remLen); var myHidden = document.getElementById('words'); myHidden.setAttribute('value',$count); } Then in whatever function you run in the form onSumbit have it run the countTheWords() function before it exits. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php