473,382 Members | 1,424 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,382 software developers and data experts.

PHP string with alert message

Hey guys, i was trying to use alert message for php string,but dunno why the alert can`t be displayed, so please help me where i did wrong, THANKS SO MUCH
here is the code:
Expand|Select|Wrap|Line Numbers
  1. <SCRIPT LANGUAGE=JAVASCRIPT>
  2. function disp_alert()
  3.          {
  4.          alert = "Serial Number Must Be Start With S";
  5.                  }
  6. </SCRIPT>
php code:
Expand|Select|Wrap|Line Numbers
  1. if(substr($sn,0,1) == "S")
  2. else
  3. {
  4. $message="Serial Number Must Be Start With S.";
JS code:
Expand|Select|Wrap|Line Numbers
  1. <input name="sn" type="text" onKeyDown="disp_alert()" "if(event.keyCode==13) event.keyCode=9 ;"size="26" >
Oct 15 '07 #1
15 7298
just changed code like this:
Expand|Select|Wrap|Line Numbers
  1. <% 
  2. if(substr($sn,0,1) == "S")    
  3.  
  4. else  
  5. {  
  6. $message="Serial Number Must Be Start With S";  
  7. echo "alert(".$message.")"; 
  8.  } 
  9. %>  
  10.  
still same, the alert window not display.
Oct 15 '07 #2
pbmods
5,821 Expert 4TB
Heya, cyberlei.

Please use CODE tags when posting source code:

[CODE=php]
PHP code goes here.
[/CODE]
Oct 16 '07 #3
sorry about that.

I already fixed that alert message issue, Thanks anyway
Oct 16 '07 #4
sorry about that.

I already fixed that alert message issue, Thanks anyway

Just post the answer here for someone who have same issue on that.

Expand|Select|Wrap|Line Numbers
  1.  
  2. echo '<script>alert("Serial Number Must Be Start With S");</script>';
  3.  
  4.  
Oct 16 '07 #5
pbmods
5,821 Expert 4TB
Heya, cyberlei.

Thanks for posting your solution.

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Oct 16 '07 #6
I have problem that there is alert msg showing but my php page (web page) is blank white page When alert box removes that page again get appears,I want the should appear and at the same time alert msg also be shown.Plz, help me!
Thanks!
Prashant
Feb 21 '08 #7
hsriat
1,654 Expert 1GB
I have problem that there is alert msg showing but my php page (web page) is blank white page When alert box removes that page again get appears,I want the should appear and at the same time alert msg also be shown.Plz, help me!
Thanks!
Prashant
Tell properly what you are trying to do, and what's happening?
Feb 21 '08 #8
Markus
6,050 Expert 4TB
I have problem that there is alert msg showing but my php page (web page) is blank white page When alert box removes that page again get appears,I want the should appear and at the same time alert msg also be shown.Plz, help me!
Thanks!
Prashant
have a look at setTimeOut() or setInterval()
Feb 21 '08 #9
yasmine
65
Just post the answer here for someone who have same issue on that.

Expand|Select|Wrap|Line Numbers
  1.  
  2. echo '<script>alert("Serial Number Must Be Start With S");</script>';
  3.  
  4.  

Hi,
Thanx 4 ur code.
But i'm having some problem with it.
The alert msg works. But when i clicks OK button, it wil goes to next reference page and not stands at the same page.
Why its happened?
What can I do?
Plz...Help me out...
Thanx n Regards
Yas
Feb 22 '08 #10
hsriat
1,654 Expert 1GB
Hi,
Thanx 4 ur code.
But i'm having some problem with it.
The alert msg works. But when i clicks OK button, it wil goes to next reference page and not stands at the same page.
Why its happened?
What can I do?
Plz...Help me out...
Thanx n Regards
Yas
What are you doing after the alert?...

You must return false after this. in the same loop as alert is.
Feb 22 '08 #11
yasmine
65
What are you doing after the alert?...

You must return false after this. in the same loop as alert is.
yah, i wrote it.
Can u give me the proper code for it...???

Thanx n Regards
Yas.
Feb 22 '08 #12
hsriat
1,654 Expert 1GB
yah, i wrote it.
Can u give me the proper code for it...???

Thanx n Regards
Yas.
[html]<form onsubmit="return onSubmitOfForm();" action="abc.php" method="post | get">[/html]
Expand|Select|Wrap|Line Numbers
  1. function onSubmitOfForm() { //use this on onsubmit of form, or onlick of submit button.
  2.     if (CONDITION==true) { //whichever condition you are verifying
  3.     return true;
  4.     else {
  5.         alert ('MESSAGE'); //your message in case condition not fulfilled
  6.         return false;
  7.     }
  8. }
If this is not what you needed, send your code. Only then I can help.

PS: Ask such questions in Javascript Forum
Feb 22 '08 #13
yasmine
65
[html]<form onsubmit="return onSubmitOfForm();" action="abc.php" method="post | get">[/html]
Expand|Select|Wrap|Line Numbers
  1. function onSubmitOfForm() { //use this on onsubmit of form, or onlick of submit button.
  2.     if (CONDITION==true) { //whichever condition you are verifying
  3.     return true;
  4.     else {
  5.         alert ('MESSAGE'); //your message in case condition not fulfilled
  6.         return false;
  7.     }
  8. }
If this is not what you needed, send your code. Only then I can help.

PS: Ask such questions in Javascript Forum

Thanx a lot.....
It's working....
But i'm having a doubt.
Is it possible to embed the same code with in PHP code...???

Thanx n Regards
Yas
Feb 22 '08 #14
hsriat
1,654 Expert 1GB
Thanx a lot.....
It's working....
But i'm having a doubt.
Is it possible to embed the same code with in PHP code...???

Thanx n Regards
Yas
Embed it in the <SCRIPT> tag in the <HEAD> of HTML

PS: It may help you if you read some basics of JavaScript
Feb 22 '08 #15
yasmine
65
Embed it in the <SCRIPT> tag in the <HEAD> of HTML

PS: It may help you if you read some basics of JavaScript

Thanx a lot for ur quick reply......
Feb 22 '08 #16

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

Similar topics

6
by: js | last post by:
I am using the following script to test if a variable is undefined or blank. The alert is not fired, if varA is blank string (ie. "", " ", " ", etc). I need to fire the alert even when varA...
5
by: Phrederik | last post by:
Hey all! New to javascript and still getting my head around strings... Consider the following line of code... var path = location.pathname; ....after execution, the variable "path"...
7
by: Michael Hill | last post by:
If I have: <a href="javascript:myfunct('cool_links')" id="cool_links"> and I refer to it as: function myfunct(mylink) { document.getElementById }
2
by: TheKeith | last post by:
can you convert a number into a string by simply adding a set of quotes like this: 5 + "" Thanks
9
by: | last post by:
Is it possible to construct a CDO.To statement based on the value of an incoming form drop down list which contains any word such as "ChangeStatus:" How would I construct the IF statement to...
8
by: Phil Powell | last post by:
if (document.location.href.indexOf('?') >= 0) document.location.href = document.location.href.substring(0, document.location.href.indexOf('?')); if (document.location.href.indexOf('#') >= 0) {...
1
by: Erik Veldkamp | last post by:
Hi there, When I use javascript I can call the alert(string) method, to show an alert window. How can I do the same when I use C# script? Thanks for your help
5
by: noddy | last post by:
What I thought was a string value does not seem to be recognised as such. In the following code I extract the string "foo" from an array and put it into the variable up0 But on checking I find...
0
by: rahat09 | last post by:
I am new to JavaScript/XML, I am trying to load xml file as well as xml as string input, and have written following code. This is working in IE but not in FireFox, can anyone help?...
1
by: rahat09 | last post by:
I am trying to load xml file as well as xml as string input, and have written following code. This is working in IE but not in FireFox, can anyone help? ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.