
August 3rd, 2003
11:28 PM
Put javascript inside a php echo function
Im tryin to put this line
<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
<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
___________________


August 3rd, 2003
11:32 PM
Just escape the double quotes:
<?php
echo "<a href = \"#\" onclick = \"playMidi('$filename.mid');\">Preview</a>";
?>
___________________


August 3rd, 2003
11:43 PM
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
___________________


August 3rd, 2003
11:44 PM
If it's a URL it would still work since it's in single quotes...
___________________


August 3rd, 2003
11:46 PM
('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
___________________


August 3rd, 2003
11:53 PM
both dont work..i feel liek such a dumass...lol
___________________


August 4th, 2003
12:00 AM
Could you show us the exact PHP code you're working with?
___________________


August 4th, 2003
12:06 AM
Its acutally a PHP download system. The pafiledb
this is a part of the code i put in
EDITED CODE
<?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
___________________

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

August 4th, 2003
12:08 AM
Hmm... Maybe just try using single quotes.
___________________


August 4th, 2003
12:10 AM
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
___________________
