CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 php to Javascript problem (another)

Print topic Send  topic

Author Message
lammy

Posts: 49
Posted: 04/13/2007, 1:24 AM

Hi all

This is another problem with php and Javascript,
the code below is held in a table in my database, This links to an affiliate site for a booking agency. What i need to do is append the user_id onto the end of the code (&no=USER_ID) so I can track who is using the site, Problem is I cant seem to get the user_id into a javascript variable. I have tried using <?=$USER_ID?> but when i run program it just shows <?=$USER_ID?> and not the actual value. I would really appreciate some help with this problem.

<script type="text/javascript">
var uri = 'http://impgb.xxxxxxxxx.com/imp?type(img)g(xxxx)a(xxxxxx)' + new String (Math.random()).substring (2, 11);
document.write('<a href="http://clkuk.xxxxxxxxxx.com/click?p=xxx&a=xxxxxxx&g=xxxx:-)&no=USER_ID:-)'" target="_blank"><img src="'+uri+'" border=0></a>');
</script>
View profile  Send private message
Damian Hupfeld
Posted: 04/13/2007, 4:19 AM

Replace USER_ID with a LABEL and use one of several methods to set its value
to that of the user.

"lammy" <lammy@forum.codecharge> wrote in message
news:5461f3e4e8321b@news.codecharge.com...
> Hi all
>
> This is another problem with php and Javascript,
> the code below is held in a table in my database, This links to an
> affiliate
> site for a booking agency. What i need to do is append the user_id onto
> the end
> of the code (&no=USER_ID) so I can track who is using the site, Problem is
> I
> cant seem to get the user_id into a javascript variable. I have tried
> using
> <?=$USER_ID?> but when i run program it just shows <?=$USER_ID?> and not
> the
> actual value. I would really appreciate some help with this problem.
>
> <script type="text/javascript">
> var uri = 'http://impgb.xxxxxxxxx.com/imp?type(img)g(xxxx)a(xxxxxx)' + new
> String (Math.random()).substring (2, 11);
> document.write('<a
> href="http://clkuk.xxxxxxxxxx.com/click?p=xxx&a=xxxxxxx&g=xxxx:-)&no=USER_ID:-)'"
> target="_blank"><img src="'+uri+'" border=0></a>');
> </script>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.yessoftware.com/
>

mkmind

Posts: 18
Posted: 04/15/2007, 10:35 PM

Hello.
You can give your Value like the UserID with a hidden Field to your Javascript. Insert a hidden Field to your Side/or Form. Set the Value from The Hidden Field in BeforeShow of it,

eg:
$yourFormName->HiddenFieldname->SetValue(CCGetUserID());


and then write your Javascript like this...

<script type="text/javascript">
var uri = 'http://impgb.xxxxxxxxx.com/imp?type(img)g(xxxx)a(xxxxxx)' + new String (Math.random()).substring (2, 11);
document.write('<a href="http://clkuk.xxxxxxxxxx.com/click?p=xxx&a=xxxxxxx&g=xxxx&no={HiddenUserID}'" target="_blank"><img src="'+uri+'" border=0></a>');
</script>

sorry about my english
greets martin k.
View profile  Send private message
teke507

Posts: 69
Posted: 04/19/2007, 7:45 PM

create a label or invisible text box whatever you like the make the default value of the textbox/label CCGetSession("User_ID")

for arguments sake say your label is named User_Id_Label

<script type="text/javascript">
var uri = 'http://impgb.xxxxxxxxx.com/imp?type(img)g(xxxx)a(xxxxxx)' + new String (Math.random()).substring (2, 11);
document.write('<a href="http://clkuk.xxxxxxxxxx.com/click?p=xxx&a=xxxxxxx&g=xxxx:-)&no={User_Id_Label}:-)'" target="_blank"><img src="'+uri+'" border=0></a>');
</script>

make sure your images src is after your label otherwise your default values will not get passed correctly by after i mean it literally make sure your label or text box is above your image src {User_Id_Label}
View profile  Send private message
teke507

Posts: 69
Posted: 04/19/2007, 7:49 PM

I just reread mkminds response and it looks like i told you the same thing sorry for the redundancy
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.