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.co m: -
<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 2827 pbmods 5,821
Recognized Expert Expert
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)
My code is below. I am getting the following error "MyForm.oNetwork.Value is Null or is not an object". I'm struggling to diagnose what to do next. I'd very much appreciate some help
Many thanks
<HTML><BODY><FORM NAME="MyForm"...
|
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 an object... the
function is like so:
function calc_total()
{
var x,i,base,margin,total,newmargin,newtotal;
base = document.frmKitAmount.txtTotalKitValue.value;
margin = document.frmKitAmount.margin.value/100;
|
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, the menu1's value would be 1.
Therefore ($answer) would be 1.
But If want using javascript get the description(ABC),which javascript
command can do it?
|
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
***********************, I've included all the code incase that isn't
where the problem is.
Any help would be hugely appreciated.
Mick
|
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 the properties:
mode1, mode2, and mode3.
This seems simple but I can't quite figure it out...
Any ideas anyone?
| |
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 the value of myVar. I need to
know how to get the value of myVar from the script up to the server.
Specifically, I'd like to have the following happen when the user clicks a
button in the browser:
1. The client-side script executes (and...
|
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 if when the list/menu (attribute6)
value is "Ja" then to make the TextField Pas Nr (attribute4)
required. And if when the list/menu (attribute6) value is "Nee" to
make the TextField Pas Nr (attribute4) not required.
|
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 will increment/decrement the form field
value by 1 when clicked.
I'm using the following code, however when I click on one of the links, I
get the following error -
|
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 debugger attached.
Actually this is about a problem iam trying to debug. And found what
the problem is and iam looking for a hack/ workaround to fix the bug.
|
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 it answered my question I am just to stupid to realize it I would like to apologize in advance. This is my very first attempt at using Javascript so any help at all is greatly appreciated. I read the W3Schools Tutorial on Javascript so that and some...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |