Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #20696
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: How to put a variable ino php script..? |
| Date | 2013-07-17 23:16 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <ks78jn$psp$8@dont-email.me> (permalink) |
| References | <ks596h$44u$1@ls237.t-com.hr> |
On Wed, 17 Jul 2013 07:13:56 +0200, Robert Bralic wrote: > I have something like this: > <a href="update.php"><?php echo $r; ?></a> > and I want to know how to pass a $r to update.php when user clicks on > link..? The $r is a php variable which is output by the php code that generates the page. In this case, it's the html content of the anchor element, which may contain other html tags, or may be plain text, or a mix of both. Any javascript on the page has no visibility of $r, it only has visibility of what is actually output to the page. As I said above, this could be plain text, html elements or a mixture of both. If you want to pass $r to update.php, the best method is to use a php session. That's way off topic for this group. If you want to read $r into a javascript variable, then at the html level you probably need to give the enclosing anchor an id, and then starting with: node = document.getElementById( "anchor_element_id" ); use dom methods to access the childnodes and / or textContent of node. If you want to pass the value of a javascript variable back to a webserver in a get or post request, one method is to create a hidden input field and put the value in there: <input type="hidden" name="hidden_1" id="hidden_1"> document.getElementById( "hidden_1" ).value = some_text_variable; And then the server can access the named field hidden_1 using the relevant server side methods (off topic here unless the server is using javascript). You should be aware in the last case that hidden fields are not guaranteed to be invisible to or unaltered by users. Anything you send to the client can and probably will at some point be manipulated in an attempt to break your website. Clients can see all the code and page source, and can manually craft responses that try and break your server. Oh, and finally, if you want to exchange data with a web server without reloading the page you can use ajax. Google ajax javascript - there's plenty of example code about. Don't forget that you may need to tweak your web server response to the ajax requests to send different content type headers. -- Denis McMahon, denismfmcmahon@gmail.com
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to put a variable ino php script..? "Robert Bralic" <robert.bralic@si.t-com.hr> - 2013-07-17 07:13 +0200
Re: How to put a variable ino php script..? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-07-17 09:25 +0200
Re: How to put a variable ino php script..? "Robert Bralic" <robert.bralic@si.t-com.hr> - 2013-07-17 09:35 +0200
Re: How to put a variable ino php script..? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-07-17 10:08 +0200
Re: How to put a variable ino php script..? "Robert Bralic" <robert.bralic@si.t-com.hr> - 2013-07-17 10:26 +0200
Re: How to put a variable ino php script..? Carlos Pedro <carlospedr@gmail.com> - 2013-07-17 03:13 -0700
Re: How to put a variable ino php script..? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-07-17 12:21 +0200
Re: How to put a variable ino php script..? "Robert Bralic" <robert.bralic@si.t-com.hr> - 2013-07-17 12:32 +0200
Re: How to put a variable ino php script..? Christoph Michael Becker <cmbecker69@arcor.de> - 2013-07-17 13:28 +0200
Re: How to put a variable ino php script..? Denis McMahon <denismfmcmahon@gmail.com> - 2013-07-17 23:16 +0000
Re: How to put a variable ino php script..? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-07-18 20:08 +0200
csiph-web