473,789 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get value from javascript to PHP

20 New Member
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:

Expand|Select|Wrap|Line Numbers
  1. function getdetail($user1)
  2. {
  3. $auser=$user1;
  4. exec("ping $auser", $coutput);
  5. foreach ($coutput as $line) {
  6. echo $line."<br />";
  7.              }
  8. }
  9.  
Below is the hint box javascript from dynamicdrive.co m:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3. /***********************************************
  4. * Show Hint script- ? Dynamic Drive (www.dynamicdrive.com)
  5. * This notice MUST stay intact for legal use
  6. * Visit http://www.dynamicdrive.com/ for this script and 100s more.
  7. ***********************************************/
  8.  
  9. var horizontal_offset="9px" //horizontal offset of hint box from anchor link
  10.  
  11. /////No further editting needed
  12.  
  13. var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
  14. var ie=document.all
  15. var ns6=document.getElementById&&!document.all
  16.  
  17. function getposOffset(what, offsettype){
  18. var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
  19. var parentEl=what.offsetParent;
  20. while (parentEl!=null){
  21. totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
  22. parentEl=parentEl.offsetParent;
  23. }
  24. return totaloffset;
  25. }
  26.  
  27. function iecompattest(){
  28. return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
  29. }
  30.  
  31. function clearbrowseredge(obj, whichedge){
  32. var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
  33. if (whichedge=="rightedge"){
  34. var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
  35. dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
  36. if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
  37. edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
  38. }
  39. else{
  40. var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
  41. dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
  42. if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
  43. edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
  44. }
  45. return edgeoffset
  46. }
  47.  
  48. function showhint(menucontents, obj, e, tipwidth){
  49. if ((ie||ns6) && document.getElementById("hintbox")){
  50. dropmenuobj=document.getElementById("hintbox")
  51. dropmenuobj.innerHTML=menucontents
  52. dropmenuobj.style.left=dropmenuobj.style.top=-500
  53. if (tipwidth!=""){
  54. dropmenuobj.widthobj=dropmenuobj.style
  55. dropmenuobj.widthobj.width=tipwidth
  56. }
  57. dropmenuobj.x=getposOffset(obj, "left")
  58. dropmenuobj.y=getposOffset(obj, "top")
  59. dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
  60. dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
  61. dropmenuobj.style.visibility="visible"
  62. obj.onmouseout=hidetip
  63. }
  64. }
  65.  
  66. function hidetip(e){
  67. dropmenuobj.style.visibility="hidden"
  68. dropmenuobj.style.left="-500px"
  69. }
  70.  
  71. function createhintbox(){
  72. var divblock=document.createElement("div")
  73. divblock.setAttribute("id", "hintbox")
  74. document.body.appendChild(divblock)
  75. }
  76.  
  77. if (window.addEventListener)
  78. window.addEventListener("load", createhintbox, false)
  79. else if (window.attachEvent)
  80. window.attachEvent("onload", createhintbox)
  81. else if (document.getElementById)
  82. window.onload=createhintbox
  83.  
  84. /* get id from <a> */
  85. function getValue()
  86. {
  87. var x=document.getElementById("computer1").id
  88. document.write(x)
  89. }
  90. </script>
  91.  
finally, the host display:
Expand|Select|Wrap|Line Numbers
  1. <a href="#"  id="computer1" onclick="showhint('<? getdetail(?>getValue()<?); ?>', this, event, '200px')">tiwlim</a>
  2.  
May i know why the final code above is not working? How do i get value from javascript -> php?

Thanks!
Nov 26 '07 #1
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.
Nov 26 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
2826
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"...
16
11501
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;
7
1913
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?
1
3436
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
16
25419
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?
6
3328
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...
1
5938
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.
5
13296
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 -
7
1585
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.
3
9864
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...
0
9656
marktang
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...
0
10177
jinu1996
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...
1
10124
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,...
0
9969
tracyyun
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...
0
8998
agi2029
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...
0
6750
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();...
0
5405
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...
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2898
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.