Hi,
I am writing a PHP script to get a ping reply from my LAN PC. So, my idea is like this, when i mouseover/mouse click to the "hostname" display on the web. There will be a hint box appear and show me the ping result. Below is the php function to perform exec: -
function getdetail($user1)
-
{
-
$auser=$user1;
-
exec("ping $auser", $coutput);
-
foreach ($coutput as $line) {
-
echo $line."<br />";
-
}
-
}
-
Below is the hint box javascript from dynamicdrive.com: -
<script type="text/javascript">
-
-
/***********************************************
-
* Show Hint script- ? Dynamic Drive (www.dynamicdrive.com)
-
* This notice MUST stay intact for legal use
-
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
-
***********************************************/
-
-
var horizontal_offset="9px" //horizontal offset of hint box from anchor link
-
-
/////No further editting needed
-
-
var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
-
var ie=document.all
-
var ns6=document.getElementById&&!document.all
-
-
function getposOffset(what, offsettype){
-
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
-
var parentEl=what.offsetParent;
-
while (parentEl!=null){
-
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
-
parentEl=parentEl.offsetParent;
-
}
-
return totaloffset;
-
}
-
-
function iecompattest(){
-
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
-
}
-
-
function clearbrowseredge(obj, whichedge){
-
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
-
if (whichedge=="rightedge"){
-
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
-
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
-
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
-
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
-
}
-
else{
-
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
-
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
-
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
-
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
-
}
-
return edgeoffset
-
}
-
-
function showhint(menucontents, obj, e, tipwidth){
-
if ((ie||ns6) && document.getElementById("hintbox")){
-
dropmenuobj=document.getElementById("hintbox")
-
dropmenuobj.innerHTML=menucontents
-
dropmenuobj.style.left=dropmenuobj.style.top=-500
-
if (tipwidth!=""){
-
dropmenuobj.widthobj=dropmenuobj.style
-
dropmenuobj.widthobj.width=tipwidth
-
}
-
dropmenuobj.x=getposOffset(obj, "left")
-
dropmenuobj.y=getposOffset(obj, "top")
-
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
-
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
-
dropmenuobj.style.visibility="visible"
-
obj.onmouseout=hidetip
-
}
-
}
-
-
function hidetip(e){
-
dropmenuobj.style.visibility="hidden"
-
dropmenuobj.style.left="-500px"
-
}
-
-
function createhintbox(){
-
var divblock=document.createElement("div")
-
divblock.setAttribute("id", "hintbox")
-
document.body.appendChild(divblock)
-
}
-
-
if (window.addEventListener)
-
window.addEventListener("load", createhintbox, false)
-
else if (window.attachEvent)
-
window.attachEvent("onload", createhintbox)
-
else if (document.getElementById)
-
window.onload=createhintbox
-
-
/* get id from <a> */
-
function getValue()
-
{
-
var x=document.getElementById("computer1").id
-
document.write(x)
-
}
-
</script>
-
finally, the host display: -
<a href="#" id="computer1" onclick="showhint('<? getdetail(?>getValue()<?); ?>', this, event, '200px')">tiwlim</a>
-
May i know why the final code above is not working? How do i get value from javascript -> php?
Thanks!
1 2800
Heya, Danny.
My guess is that the ping command on the server side is sending an unlimited number of pings. Since the exec() command doesn't return anything until the command is finished, it never returns.
Try using the -c parameter for ping to limit the number of pings sent. `man ping` for more information.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: NewbieJon |
last post by:
I am attempting to send the variable "sComputerName" from my ActiveX script to "GetInfo.asp" using javascript. (Having been advised this is the way to get my ActiveX variable into my ASP script)
...
|
by: cwizard |
last post by:
I'm calling on a function from within this form, and there are values set
but every time it gets called I get slammed with a run time error...
document.frmKitAmount.txtTotalKitValue is null or not...
|
by: ???????J |
last post by:
Javascript may inquire the push down menu value, can I inquire the
description?
The following example, the variable($answer) can be get the menu1's
value.
For example, if I select first data,...
|
by: MickG |
last post by:
I am trying to change the value of the variable "hard" according to
which radio button is pressed and I am having no joy. Could anyone
help me with this, the problematic section is marked with...
|
by: sneill |
last post by:
How is it possible to take the value of a variable (in this case,
MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name?
In the following example I want 'oIcon' object to have...
|
by: Guadala Harry |
last post by:
I have some client-side JavaScript that, among other things, calculates the
value of a variable (myVar). On the server I have a stored procedure that
needs to somehow receive as an input parameter...
|
by: platostoteles |
last post by:
Hallo NG,
I am new to JavaScript and would really appreciate any help to solve my
problem.
I am using the blow code in my form to validate form fields. What I
would like to accomplish is that...
|
by: Stuart |
last post by:
Hi all,
Iv'e got a page that has a mass amount of input fields, all of which require
a decimal figure. To make it easier when it comes to inputting data, I'm
trying to setup + and - links that...
|
by: ravi |
last post by:
Hi,
I am a newbie to javascript.
Iam working on a page that has two radio buttons and a tree. I do not
have my tree nodes to be selectable.
Iam working on Firefox.
I have the firebug...
|
by: zac540 |
last post by:
Hey everyone!
First of all I'd like to say that I did my best to look for any other relevant posts. The best I found was this interesting thread.. http://bytes.com/forum/thread594982.html
If...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |