RE: [PHP-DB] php variables to JS
Forget hidden form all you have to do is to insert in javascript code php code like this: . ... weight= height= ..and so on it's simple no??? i hope it's good for your needs cybercop78 On Sun, 5 Jan 2003 08:36:20 -0600, Bryan McLemore wrote > Could always pass it through a hidden form. > > Bryan > > -Original Message- > From: Bruce Levick [mailto:[EMAIL PROTECTED]] > Sent: Sunday, January 05, 2003 1:09 AM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] php variables to JS > > Bruce Levick - VivamotionI am opening a chromless window with some JS > code. > I need to pass some variables which come from rows in my database > into the jscript which will determine the size and URL of the window. > > Before I go about drawing the info from the database I have set up some > hard > code php variables just so i could test how to pass these into js. > > Does anybody know how I can code these variables into my jscript?? > > Cheers > > ## > $h = 600; > $w = 343; > $theURL = test.php; > $wname = test; > ?> > ### > > ## > SRC="js/java.js"> > > > > > ## > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php http://www.idilis.ro - Stiri, e-mail gratuit, download, SMS, server de counter-strike, hosting gratuit, servicii internet... Fii cu un pas inaintea celorlati! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] php variables to JS
OK. I consider this an easier way. I use it to display fullsize images when a thumbdnail is clicked. Same principle. >From var pixNum="",winName="", mheight="", mwidth="" var pixURL="http://**someURL**/"; function viewPix(pixNum,winName,mheight,mwidth) { win = window.open(pixURL+pixNum,winName,"status=no,toolbar=no,location=no,menu =no,scrollbars=yes,resizable=yes,width="+ mwidth + ",height=" + mheight +'"'); } >From (snip...) (snip ...) This is used to display a large image after clicking on a thumbnail. The principle is the same regardless what you want to pass to the scripts. Hope there is some inspiration here. Regards, Doug On Sun, 5 Jan 2003 09:35:04 -0500, Rich Hutchins wrote: >>From what I have learned PHP and JS don't "talk" directly to each other. >Instead, you have to make hidden fields in your html that hold the values >from your database then access those hidden fields with JS. If you want to >take values from JS and use them in a PHP script, then the process is >reversed; make hidden fields, set their values with JS then pass the hidden >fields to a PHP script. > >In your case the relevant (abbreviated and untested) PHP code might look >like this: > //where $dbWindowHeight is avariable that has been assigned a value from >your dbquery > echo "". > "". > ""; >?> > >The relevant JS might look something like this: >var height = document.form.windowHeight.value; > >Then for your window.open JS call, you'd substitute the var named height >into the string with the rest of the chromeless information. > >If anybody knows an easier way, please post it because I'd love an easier >alternative if one exists. > >Hope this helps. If not, I know there's a wealth of info in the PHP archives >about this subject. That's where I learned. > >Rich > >-Original Message- >From: Bruce Levick [mailto:[EMAIL PROTECTED]] >Sent: Sunday, January 05, 2003 2:09 AM >To: [EMAIL PROTECTED] >Subject: [PHP-DB] php variables to JS > > >Bruce Levick - VivamotionI am opening a chromless window with some JS code. >I need to pass some variables which come from rows in my database into the >jscript which will determine the size and URL of the window. > >Before I go about drawing the info from the database I have set up some hard >code php variables just so i could test how to pass these into js. > >Does anybody know how I can code these variables into my jscript?? > >Cheers > >## >$h = 600; >$w = 343; >$theURL = test.php; >$wname = test; >?> >### > >## >SRC="js/java.js"> > > > > >## > > > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php > > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] php variables to JS
One minor error I found upon re-reading is that I neglected to assign a name to the hidden field in HTML. Without doing so, the JS statement wouldn't work. So, the hidden field would actually need to look like this: echo "". etc... -Original Message- From: Rich Hutchins [mailto:[EMAIL PROTECTED]] Sent: Sunday, January 05, 2003 9:35 AM To: Bruce Levick; [EMAIL PROTECTED] Subject: RE: [PHP-DB] php variables to JS >From what I have learned PHP and JS don't "talk" directly to each other. Instead, you have to make hidden fields in your html that hold the values from your database then access those hidden fields with JS. If you want to take values from JS and use them in a PHP script, then the process is reversed; make hidden fields, set their values with JS then pass the hidden fields to a PHP script. In your case the relevant (abbreviated and untested) PHP code might look like this: ". "". ""; ?> The relevant JS might look something like this: var height = document.form.windowHeight.value; Then for your window.open JS call, you'd substitute the var named height into the string with the rest of the chromeless information. If anybody knows an easier way, please post it because I'd love an easier alternative if one exists. Hope this helps. If not, I know there's a wealth of info in the PHP archives about this subject. That's where I learned. Rich -Original Message- From: Bruce Levick [mailto:[EMAIL PROTECTED]] Sent: Sunday, January 05, 2003 2:09 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] php variables to JS Bruce Levick - VivamotionI am opening a chromless window with some JS code. I need to pass some variables which come from rows in my database into the jscript which will determine the size and URL of the window. Before I go about drawing the info from the database I have set up some hard code php variables just so i could test how to pass these into js. Does anybody know how I can code these variables into my jscript?? Cheers ## ### ## <!-- function openIT() { theURL="wesley.php"//php variable here wname ="CHROMELESSWIN" //php variable here W=300; //php variable here H=100; //php variable here windowCERRARa = "images/close_a.gif" windowCERRARd = "images/close_d.gif" windowCERRARo = "images/close_o.gif" windowNONEgrf = "images/none.gif" windowCLOCK = "images/clock.gif" windowREALtit = " ? Task title" windowTIT = "<font face=verdana size=1> your chromless</font>" windowBORDERCOLOR = "#00" windowBORDERCOLORsel = "#00" windowTITBGCOLOR = "#FF0033" windowTITBGCOLORsel = "#FF0033" openchromeless(theURL, wname, W, H, windowCERRARa, windowCERRARd, windowCERRARo, windowNONEgrf, windowCLOCK, windowTIT, windowREALtit , windowBORDERCOLOR, windowBORDERCOLORsel, windowTITBGCOLOR, windowTITBGCOLORsel) } //--> ## -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] php variables to JS
Could always pass it through a hidden form. Bryan -Original Message- From: Bruce Levick [mailto:[EMAIL PROTECTED]] Sent: Sunday, January 05, 2003 1:09 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] php variables to JS Bruce Levick - VivamotionI am opening a chromless window with some JS code. I need to pass some variables which come from rows in my database into the jscript which will determine the size and URL of the window. Before I go about drawing the info from the database I have set up some hard code php variables just so i could test how to pass these into js. Does anybody know how I can code these variables into my jscript?? Cheers ## ### ## ## -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] php variables to JS
>From what I have learned PHP and JS don't "talk" directly to each other. Instead, you have to make hidden fields in your html that hold the values from your database then access those hidden fields with JS. If you want to take values from JS and use them in a PHP script, then the process is reversed; make hidden fields, set their values with JS then pass the hidden fields to a PHP script. In your case the relevant (abbreviated and untested) PHP code might look like this: ". "". ""; ?> The relevant JS might look something like this: var height = document.form.windowHeight.value; Then for your window.open JS call, you'd substitute the var named height into the string with the rest of the chromeless information. If anybody knows an easier way, please post it because I'd love an easier alternative if one exists. Hope this helps. If not, I know there's a wealth of info in the PHP archives about this subject. That's where I learned. Rich -Original Message- From: Bruce Levick [mailto:[EMAIL PROTECTED]] Sent: Sunday, January 05, 2003 2:09 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] php variables to JS Bruce Levick - VivamotionI am opening a chromless window with some JS code. I need to pass some variables which come from rows in my database into the jscript which will determine the size and URL of the window. Before I go about drawing the info from the database I have set up some hard code php variables just so i could test how to pass these into js. Does anybody know how I can code these variables into my jscript?? Cheers ## ### ## ## -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php