473,396 Members | 1,813 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 send data from Javascript to PHP code

18
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function display_check(i)
  3. {
  4.     if(i==0) {return true;}
  5.     else if(i!=0) {return false;}
  6. }
  7.  
  8. function run()
  9. {
  10.     if (t-1 >= 0)
  11.     {
  12.         t = t - 1; 
  13.         document.getElementsByValue('text').innerHTML =display_check(t);
  14.     }
  15. }
  16. </script>
  17. <body>
  18. <input type="button" onclick="run()" />
  19. <?
  20. $text = "<p id=\"text\"></p>"
  21. echo $text;
  22. ?>
  23. </body>
This case can display the "false" and "true" on the screen. But cnt display in if else statement.
who know other way can use in if else statement to display? Thank you.

notice: Please enclose your posted code in [code] tags (See How to Ask a Question). So use [code] tags in future. - MODERATOR
Mar 25 '08 #1
4 3433
TheServant
1,168 Expert 1GB
Doesn't make sense. You have your php calling one function which calls another? What "if else" statement are you talking about?
Mar 25 '08 #2
SeeMe
18
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function display_check(i)
  3. {
  4. if(i==0) {return true;}
  5. else if(i!=0) {return false;}
  6. }
  7.  
  8. function run()
  9. {
  10. if (t-1 >= 0)
  11. {
  12. t = t - 1; 
  13. document.getElementsByValue('text').innerHTML =display_check(t);
  14. }
  15. }
  16. </script>
  17. <body>
  18. <input type="button" onclick="run()" />
  19. <?
  20. $text = "<p id=\"text\"></p>";
  21. /******************if else statement***********************/
  22. if ($text == true)
  23. {echo "finish";}
  24. else if ($text == false)
  25. {echo "running!";}
  26. /************************************************************/
  27. ?>
  28. </body>
my if else statement show an above. thank you
Mar 25 '08 #3
hsriat
1,654 Expert 1GB
This case can display the "false" and "true" on the screen. But cnt display in if else statement.
who know other way can use in if else statement to display? Thank you.
Unfortunately, there are lots of mistakes and bad algorithms in your program.
First of all you should know that JavaScript and PHP are not executed together.
PHP runs on the server and sends HTML and JavaScript to the browser. On the browser, runs the JavaScript.
And there is nothing called getElementByValue in JavaScript.
If a condition provided in an if statement is not true, it automatically executes the else statement. You don't have to provide the opposite condition in another if statement.
Mar 25 '08 #4
ronverdonk
4,258 Expert 4TB
warning: Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

MODERATOR
Mar 25 '08 #5

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

Similar topics

15
by: Steve Horrillo | last post by:
I can't figure out why this script won't insert the subject in the email and why can't I control the font and size being used? I'm not sure where to post this. Let me know where if this is OT. ...
5
by: Dan | last post by:
Hi, Is there a way to send information via javascript by redirecting to a page that contains frames? The information that will have to be sent will be the page name of the original page before...
2
by: thumer | last post by:
First I want to excuse me for my bad english. I have programmed a javascript application, like a file browser. You can create move, delete and create files and folders. The data is saved in a...
9
by: Mahernoz | last post by:
Can i send an email from JavaScript? Is it possible? If yes please the code to send email using javascript...
4
by: David A. Beck | last post by:
I need to enter data on a web page. I have been able to navigate using the VB.NET WebBrowser control and see the contents of each page. What I need to do now is to fill in the controls on the page...
1
by: steinwaygirl | last post by:
Hi all, I have been searching so hard for the answer to this, hopefully some of you all can help. I have created an HTML file with various forms - also included CSS and some javascript for...
1
by: Malli mindwave | last post by:
Hi, I want to send form data to given email id, I'm using mailto:ur@mail.com, but it doesn't working it dirsctly goes to localSystem A/C i.e outlook.. <form name="form1" method="post"...
2
by: Malli mindwave | last post by:
Hi, We are using the yahoowebHostiing service for my company website, In that one screen of the SendComments/FeedBack section is there, I'm basically dot.net develeoper ,but yahoowebhosting not...
2
by: ajaxcoder | last post by:
Hi In my project i had a login form and i am trying to send the username and password to the server for authentication using xmlHttpRequest. Hence i am using POST request but i am unable to send...
1
by: toretto | last post by:
Hello, I have a script php that I use on my website to permit visitors to send me some email with some data, this is the html table code: <table width="730" border="0" cellpadding="0"...
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: 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...
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
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
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...
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...
0
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,...

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.