Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
Due to network maintenance being performed by our provider, LQ will be down starting at 05:01 AM UTC. The exact duration of the downtime isn't currently known. We apologize for the inconvenience.
|
 |
06-27-2006, 05:58 PM
|
#1
|
|
Member
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408
Rep:
|
combining JavaScript and PHP
I have decleared a function by Javascript before body of my page:
Code:
<script type="text/javascript">
<!-- Hide the script
function warn_on_submit()
{
var msg = "Are you sure, Dude????";
if (confirm(msg))
location.replace('update.php');
else
location.replace('java.php');>";
}
// end hiding -->
</script>
I have a form inside my PHP and I want to call my JavaScript function when onClick event is occured:
PHP Code:
print "<form method='POST' action='update.php' name='form1'>";
print "<input type='hidden' name='unique_id' value='{$unique_id}'>";
print "<input type='submit' value='update' onClick='warn_on_submit();'>";
print "</form>";
But when I submit the form I don't see any message asking for confirmation.
I am quite new to Javascript so excuse me if it was a stupid question
|
|
|
|
06-27-2006, 09:49 PM
|
#2
|
|
Member
Registered: Jul 2004
Location: louisiana
Distribution: fedora 4/kubuntu
Posts: 116
Rep:
|
It is that extra >"; you have in your else statement.
|
|
|
|
06-28-2006, 07:48 AM
|
#3
|
|
Member
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408
Original Poster
Rep:
|
thank you very much. I should have been more careful about that.
my new problem is that when I press ok or cancel i got to update.php and cancel button doesn't do anything in this page
|
|
|
|
06-28-2006, 08:38 AM
|
#4
|
|
Member
Registered: Mar 2003
Location: Berkshire, England.
Distribution: SuSE 10.0
Posts: 299
Rep:
|
If you're using Firefox, you can use its built-in Javascript console to help you spot things like this.
Assuming you've got it set up the way I have, you should find the Javascript console option in the tools menu; any JS errors will show up in there, with their line numbers and error message. It would probably have helped you a lot in this case.
Other browsers also have features that do the same thing, but Firefox is the best for debugging JS, IMHO.
|
|
|
|
06-28-2006, 11:02 AM
|
#5
|
|
Member
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408
Original Poster
Rep:
|
Here is the error which is written in Javascript console of Firefox:
Error: Expected ':' but found '='. Declaration dropped.
Source File: http://mohi/change.php
Line: 0
Everything seems correct 
|
|
|
|
07-03-2006, 05:10 PM
|
#6
|
|
Member
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408
Original Poster
Rep:
|
I run this simple html file which contains javascript. but it doesn't show anything on my firefox webbrowser.even JavaScript console doesn't show anything
Quote:
<HTML>
<HEAD>
</HEAD>
<script language="javascript">
function versio()
{
document.write('<b>Your browser supports JavaScript ' + js_version + '</b>')
}
</script>
<!-- start the frame animation when the document is fully loaded -->
<BODY onLoad="versio();" >
</BODY>
</HTML>
|
Last edited by mohtasham1983; 07-03-2006 at 05:12 PM.
|
|
|
|
07-03-2006, 07:01 PM
|
#7
|
|
Senior Member
Registered: Aug 2005
Posts: 1,755
Rep:
|
Quote:
|
Originally Posted by mohtasham1983
I run this simple html file which contains javascript. but it doesn't show anything on my firefox webbrowser.even JavaScript console doesn't show anything
|
Error: js_version is not defined
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 08:31 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|