Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

91 users online



Put javascript inside a php echo function

Put javascript inside a php echo function

Currently viewing this thread: 1 (0 members and 1 guests)


Page 1 out of 2
hamidrizvi

hamidrizvi

Status: Offline!

Put javascript inside a php echo function

Im tryin to put this line

Code:

<a href = "#" onclick = "playMidi('paper.mid');">Preview</a>

inside a php echo function. How can i do it? because the " and ' mess everything up.

O..and to make it worse, insted of jus simple puttin paper.mid, Im actually tryin to make it a link that uses a variable. Example

Code:


<a href = "#" onclick = "playMidi('http://www.domain.com/[b]variable goes here[/b].mid');">Preview</a>

could someone plllz tell me how to put all that inside a PHP function...thx

___________________

http://www.nauhay.com/images/sig1.jpg

fredmv

fredmv

Status: Offline!

Just escape the double quotes:

PHP:


<?php
  
echo "<a href = \"#\" onclick = \"playMidi('$filename.mid');\">Preview</a>";
?>

___________________

http://home.comcast.net/~fredv4/tf/firefox.gif

hamidrizvi

hamidrizvi

Status: Offline!

yay...but the thing is..instead of jsut the variable...its actually a whole URL...so what kinda quotes do i pur around the URL? cuz its supposed to be single, but if i put those..everything is gonna get messed

___________________

http://www.nauhay.com/images/sig1.jpg

fredmv

fredmv

Status: Offline!

If it's a URL it would still work since it's in single quotes...

___________________

http://home.comcast.net/~fredv4/tf/firefox.gif

hamidrizvi

hamidrizvi

Status: Offline!

('http://www.desitonez.com/tones/aankhen/midi/'$file[file_name]'.mid')

OR

('http://www.desitonez.com/tones/aankhen/midi/$file[file_name].mid')
sorry for sounding so stupid

___________________

http://www.nauhay.com/images/sig1.jpg

hamidrizvi

hamidrizvi

Status: Offline!

Sad both dont work..i feel liek such a dumass...lol

___________________

http://www.nauhay.com/images/sig1.jpg

fredmv

fredmv

Status: Offline!

Could you show us the exact PHP code you're working with?

___________________

http://home.comcast.net/~fredv4/tf/firefox.gif

hamidrizvi

hamidrizvi

Status: Offline!

Its acutally a PHP download system. The pafiledb

this is a part of the code i put in

EDITED CODE

PHP:


<?php echo $file[file_name];?> <?php echo "<a href = \"#\" onclick = \"playMidi('http://www.desitonez.com/tones/aankhen/midi/$file[file_name].mid');\">Preview</a>" ;?>

This is the file Im working on, I have no idea whats goin on in half of it, I jsut want this one part to work

Attachments:

file.txt (Download) 5.46 Kb, 27 views

___________________

http://www.nauhay.com/images/sig1.jpg

Last edited by hamidrizvi, August 4th, 2003 12:12 AM (Edited 1 times)

fredmv

fredmv

Status: Offline!

Hmm... Maybe just try using single quotes.

___________________

http://home.comcast.net/~fredv4/tf/firefox.gif

hamidrizvi

hamidrizvi

Status: Offline!

yea..for that, I had jsut made 2 echo functions as you will see in the txt file

The php file works now, but the thing is, its a javascript error "Object expected". So i think the variable isnt being read or sumthing

___________________

http://www.nauhay.com/images/sig1.jpg

Page 1 out of 2
Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.009 seconds.