Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #20685 > unrolled thread

How to put a variable ino php script..?

Started by"Robert Bralic" <robert.bralic@si.t-com.hr>
First post2013-07-17 07:13 +0200
Last post2013-07-18 20:08 +0200
Articles 11 — 6 participants

Back to article view | Back to comp.lang.javascript


Contents

  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

#20685 — How to put a variable ino php script..?

From"Robert Bralic" <robert.bralic@si.t-com.hr>
Date2013-07-17 07:13 +0200
SubjectHow to put a variable ino php script..?
Message-ID<ks596h$44u$1@ls237.t-com.hr>
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..?

Thanks, Robert...;) 

[toc] | [next] | [standalone]


#20686

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2013-07-17 09:25 +0200
Message-ID<XnsA2005FDAECEA6eejj99@194.109.133.133>
In reply to#20685
Robert Bralic wrote on 17 jul 2013 in comp.lang.javascript:

> 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..?

Better ask in a php NG.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#20687

From"Robert Bralic" <robert.bralic@si.t-com.hr>
Date2013-07-17 09:35 +0200
Message-ID<ks5hgv$a4b$1@ls237.t-com.hr>
In reply to#20686
"Evertjan." <exxjxw.hannivoort@inter.nl.net> wrote in message 
news:XnsA2005FDAECEA6eejj99@194.109.133.133...
> Robert Bralic wrote on 17 jul 2013 in comp.lang.javascript:
>
>> 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..?
>
> Better ask in a php NG.
>
> -- 
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)

But I want to do this with Javascript..

Thanks, Robert..;) 

[toc] | [prev] | [next] | [standalone]


#20688

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2013-07-17 10:08 +0200
Message-ID<XnsA20067199D868eejj99@194.109.133.133>
In reply to#20687
Robert Bralic wrote on 17 jul 2013 in comp.lang.javascript:


> "Evertjan." <exxjxw.hannivoort@inter.nl.net> wrote in message 
>> Robert Bralic wrote on 17 jul 2013 in comp.lang.javascript:
>>
>>> 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..?
>>
>> Better ask in a php NG.

[please do not quote signatures on NG's

> But I want to do this with Javascript..

Why? What would the programming language add?

This $r seems to me something on the php-server,
whe Javascript programmers wouln'd necesarily know about.

You could perhaps change servers and use serverside JS?
Or you could add a querystring extension to the href with php?

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#20689

From"Robert Bralic" <robert.bralic@si.t-com.hr>
Date2013-07-17 10:26 +0200
Message-ID<ks5kfj$ccg$1@ls237.t-com.hr>
In reply to#20688
"Evertjan." <exxjxw.hannivoort@inter.nl.net> wrote in message 
news:XnsA20067199D868eejj99@194.109.133.133...
> Robert Bralic wrote on 17 jul 2013 in comp.lang.javascript:
>
>
>> "Evertjan." <exxjxw.hannivoort@inter.nl.net> wrote in message
>>> Robert Bralic wrote on 17 jul 2013 in comp.lang.javascript:
>>>
>>>> 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..?
>>>
>>> Better ask in a php NG.
>
> [please do not quote signatures on NG's
>
>> But I want to do this with Javascript..
>
> Why? What would the programming language add?
>
> This $r seems to me something on the php-server,
> whe Javascript programmers wouln'd necesarily know about.
>
> You could perhaps change servers and use serverside JS?
> Or you could add a querystring extension to the href with php?
>
> -- 
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)

My Question Is:
How to make with javascript that when user cliks a link, that some value
pass to php script...

Thanks, Robert...;) 

[toc] | [prev] | [next] | [standalone]


#20691

FromCarlos Pedro <carlospedr@gmail.com>
Date2013-07-17 03:13 -0700
Message-ID<be95468c-7782-4e98-9f48-61d5ab9e5273@googlegroups.com>
In reply to#20689
Again this is a PHP question. I guess here would be a nice place to start:
http://php.net/manual/en/reserved.variables.get.php

[toc] | [prev] | [next] | [standalone]


#20692

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2013-07-17 12:21 +0200
Message-ID<XnsA2007DCAD316Aeejj99@194.109.133.133>
In reply to#20689
Robert Bralic wrote on 17 jul 2013 in comp.lang.javascript:

> 
> "Evertjan." <exxjxw.hannivoort@inter.nl.net> wrote in message 
> news:XnsA20067199D868eejj99@194.109.133.133...
>> Robert Bralic wrote on 17 jul 2013 in comp.lang.javascript:
>>
>>
>>> "Evertjan." <exxjxw.hannivoort@inter.nl.net> wrote in message
>>>> Robert Bralic wrote on 17 jul 2013 in comp.lang.javascript:
>>>>
>>>>> 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..?
>>>>
>>>> Better ask in a php NG.
>>
>> [please do not quote signatures on NG's
>>
>>> But I want to do this with Javascript..
>>
>> Why? What would the programming language add?
>>
>> This $r seems to me something on the php-server,
>> whe Javascript programmers wouln'd necesarily know about.
>>
>> You could perhaps change servers and use serverside JS?
>> Or you could add a querystring extension to the href with php?
>>
>> -- 
>> Evertjan.
>> The Netherlands.
>> (Please change the x'es to dots in my emailaddress)

DID YOU READ MY RESPONSE? [1]
>> [please do not quote signatures on NG's]

> My Question Is:
> How to make with javascript that when user cliks a link, that some value
> pass to php script...

DID YOU READ MY RESPONSE? [2]

PHP script is in a file on the server,
the server would have to rewrite the file to change te script.

Perhaps you ment to pass a value to a php serverside process?

You do not need Javascript for that.

<a href="update.php?r=<?php echo $r; ?>"><?php echo $r; ?></a>

will do fine, but is OFF TOPIC on this NG,
as it does not make use of Javascript.

DID YOU READ MY QUESTION? [3]

>> Why? What would the programming language add?

Do you need a Javascript answer 
because it is stated in your homework to do so?

If so, please don't cheat, make your own homework.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#20693

From"Robert Bralic" <robert.bralic@si.t-com.hr>
Date2013-07-17 12:32 +0200
Message-ID<ks5rr8$i6r$1@ls237.t-com.hr>
In reply to#20692
Sorry friend AJAX is part of javascript not php...

Thanks, Robert..;) 

[toc] | [prev] | [next] | [standalone]


#20694

FromChristoph Michael Becker <cmbecker69@arcor.de>
Date2013-07-17 13:28 +0200
Message-ID<51e67f7d$0$6582$9b4e6d93@newsspool3.arcor-online.net>
In reply to#20693
Robert Bralic wrote:

> Sorry friend AJAX is part of javascript not php...

Well, I would rather say, that the XMLHttpRequest object is part of
several host environments of ECMAScript implementations.

See the newsgroup's FAQ, section 11.1[1][2], for some links to further
information.

[1] <http://jibbering.com/faq/#ajax>
[2] <http://pointedears.de/scripts/faq/cljs/#ajax>

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#20696

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2013-07-17 23:16 +0000
Message-ID<ks78jn$psp$8@dont-email.me>
In reply to#20685
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

[toc] | [prev] | [next] | [standalone]


#20698

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2013-07-18 20:08 +0200
Message-ID<2254679.j3ESebKCLd@PointedEars.de>
In reply to#20685
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 simple and off-topic answer is:

<a href="update.php?<?php echo htmlspecialchars($r); ?>"
   ><?php echo $r; ?></a>

If that is not what you are looking for, be more precise.  (What is “$r”?)

-- 
PointedEars

Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web