473,396 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to get value from JavaScript function

Expand|Select|Wrap|Line Numbers
  1. /*This is time counter -it will update every minute
  2. I want to get the value from javascript and save it to database?
  3. */
  4.  
  5. <form name="myForm" method="post">
  6.  
  7. <script type="text/javascript"> 
  8. var num = 0;
  9. function IncCounter() { 
  10. num = num + 1;   // increment counter by 2
  11. document.myForm.counter.value = num;
  12. t = setTimeout('IncCounter()', 600);   // run once per minute
  13.  
  14.  
  15. </script>
  16.  
  17. <?
  18. $conn=mysql_connect("localhost","root","root") or die("Cannot connect to server");
  19. mysql_select_db("test",$conn) or die("cannot select database");
  20.  
  21. echo "<input name=\"counter\" type=\"text\" onFocus=\"IncCounter()\"> " //how save this value to database?
  22. echo "<label id=\"counter\" onfocus=\"IncCounter()\"> </label>" //how to get the value and view as label
  23. ?>
  24. </form>

hope all senior here could help
Jan 4 '12 #1
1 2027
johny10151981
1,059 1GB
create a hidden type input field in the form

and in the IncCounter function set the hidden field value with the incremented value. by the way, your label tag will never get focus, as far i can recall...
Jan 4 '12 #2

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

Similar topics

0
by: Prescott | last post by:
I want to execute a javascript function that will set a value in the parent window from the child widow where its called and then post the form to the server. I seem to be able to execute one or...
4
by: William | last post by:
My first time posting to clj , I have already read http://jibbering.com/faq/#FAQ2_3 before posting. javascript function in question: saveText() is as follows: function saveText(...
4
by: mantrid | last post by:
Can anyone see why the checkbox in the code below doesnt get ticked when the textbox is changed ***This javascript function is called in the textbox's onchange event to check it when it is...
5
by: IchBin | last post by:
Not sure if I should post this to a javascript group or here. So I'll try here first since most here mix both in this group. I am trying to pass a php value into a JavaScript function that changes...
1
by: susmitha | last post by:
hai iam a fresher in .net.My problem is I have one javascript sourcefile and some javascript functions in my aspx page like shown below. <script language=javascript...
1
by: --[zainy]-- | last post by:
Hello Guyz.. I want to assign a varascript value to a session object in javascript function... like i have an image and onClick i am calling a function sort_(str).. Now i want to assign this...
3
by: chinki | last post by:
I'm facing a problem in form related to employee Leave which has two asp controls with calendar image which is built in javascript as, <asp:textbox id="txtlsdate" runat="server"...
2
by: moni | last post by:
Hi, I wanted to call a javascript function function showAddress(address) { ..... } from the aspx.cs file from the Gridview_RowCommand function
7
by: pardesiya | last post by:
Friends, I need to write a javascript function (which will be called on clicking a button) to return the currently selected item from a drop- down list whose rendered html is below. <select...
10
by: evicailieva | last post by:
A have a php scrip where I call a JavaScript function. I don't know why, but it doesn't work. At the beginning, when I was writing the script it was working but now it's not. I don't know wхat to do....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...

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.