How to use txt content to onclick="doAjaxCall(' ')?

时间:2016-04-21 22:49:42

标签: php onclick

I use voice xml to select logo or movie. Put logo.svg or movie.php in the txt file. Then I use php to load the logo.svg or movie.php to the $theData.

<?php
ini_set("display_errors", true);

// define your file name as a variable
$myFile = "voice.txt";

// get a FILE HANDLE to the file: 'r' means set permission to read
$fh = fopen($myFile, 'r');

//read the entire file and store the contents in the variable $theData
$theData = fread($fh, filesize($myFile));

// close the file so it will be OK to use later
fclose($fh);

//echo  whatever is in the file back to the browser
echo $theData;



// PART 2
// get a FILE HANDLE to the file: 'a' means set permission to read
$fh = fopen($myFile, 'w') or die("Error trying to open with a");

$noData = "no msgs";

//read the entire file and store the contents in the variable $theData
$theData = fwrite($fh, $noData);

// close the file so it will be OK to use later
fclose($fh)

?>

Now I want to show either of them on the webs. I use:

<input class="logo" type="button" value="Call (832) 271-6319 " onclick="doAjaxCall('  ');"/>

How can I do it? Should I use javascript?

1 个答案:

答案 0 :(得分:0)

我不确定你想要达到什么目标。 onclick允许您添加像

这样的javascript函数
<input onclick="myFunction()" />

您可以通过此功能进行ajax调用。 或者您可以使用jquery并将函数附加到输入单击事件。

$(".logo").click(function(){
.....
});