javascript alert message!

This is a discussion on "javascript alert message!" within the JavaScript Forum section. This forum, and the thread "javascript alert message! are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 27th, 2004, 03:36
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
javascript alert message!

I have a textbox...named "bnBookingStatus"..
Code: Select all
<input id="status" type="text" name="bnBookingStatus" size="35" value="<%=(conformBookingBN.Fields.Item("bnBookingStatus").Value)%>" readonly>
The text box is disable from user input, but i proved a text button to change the value inside it!

Code: Select all
[Approve] 
[Disapprove] 
[Pending]
and i have another textbox, named "reason"..
Code: Select all
<input id="reason" type="text" name="bnReason" size="35">
What i want to do is...
I want to create a javascript alert message if the value in the two textbox is like the LOGIc below when i trying to submit the form:-

bnBookingStatus="DISAPPROVE" && reason=""

If "bnBookingStatus" textbox value is "DISAPPROVE" and "reason" textbox value is empty,""
then alert that user to fill in the "reason" textbox!
alert("You must specify the disapproval reason!");

If the "bnBookingStatus" textbox value is "APPROVED",
then set the value of the textbox "reason" to be "YOUR BOOKING HAS BEEN PROCESSED!"

If it is pending, DO NOTHING!
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)

  #2 (permalink)  
Old Sep 27th, 2004, 18:16
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
NOT TESTED!!!!!!

Code: Select all
<SCRIPT language="JScript>
function Validate(str){
 if(str=="disapprove"){
  document.getElementById('reason').readonly = false;
  document.getElementById('reason').value = '';
  alert('give me a reason!!!!!!!');
 }
 else if(str=="approve"){
  document.getElementById('reason').value = 'YOUR BOOKING HAS BEEN PROCESSED!!!!!';  
  document.getElementById('reason').readonly = true;
 }
 else{ // pending, do nothing
  
 }
}
</SCRIPT>
<SELECT id="status" name="bnBookingStatus" onChange="Validate(this.value)">
 <option value="pending">pending</option>
 <option value="disapprove">disapprove</option>
 <option value="approve">approve</option>
</SELECT>



<input id="reason" type="text" name="bnReason" size="35">
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
  #3 (permalink)  
Old Sep 28th, 2004, 01:50
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
hey...thanx spinal007

just a tought, you are using a DROP DOWN menu to change the textbox!
but i dont want to do that. I prefer using the text link:

Code: Select all
[Approve] 
[Disapprove] 
[Pending]
...since the initial value in this textbox(bnBookingStatus) comes from my database recordset(Edit page)

so....
Can I put the onClick="Validate(this.value)" in my submit button?
will it work? Validate(this.value)??
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
  #4 (permalink)  
Old Sep 28th, 2004, 10:16
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
you can still use a select box when the data comes from a database. like this:
Code: Select all
<SELECT name=test>
 <option value="approve"<% If rs("status")="approve" %> SELECTED<% End If %>>approve</option>
 <option value="disapprove"<% If rs("status")="disapprove" %> SELECTED<% End If %>>disapprove</option>
 <option value="pending"<% If rs("status")="pending" %> SELECTED<% End If %>>pending</option>
</select>
it's neater.......

and if you want the validation to happen ONLY when the submit button is clicked, you can use this:
<INPUT type=submit onclick="return Validate(document.getElementById('status').value); " value="submit">

the keyword "this" refers to the object itself, e.g.:
<input type=button MyProperty="some text" onClick="alert(this.MyProperty);" value="click me">
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
  #5 (permalink)  
Old Sep 29th, 2004, 01:43
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
Ok, let me try them out first...
in the mean time i have another doubt!

i have a disable text field in my form...
i have used this code on a text link to enable field..

[code]
[b]TEXT LINK


When i click the TEXT LINK, the value of textbox which ID is "status" will be set to "APPROVED"
and at the same time it will enable the textbox which ID is "reason"?

Code: Select all
<input id="status" type="text" name="bnBookingStatus" size="35" value="<%=from recordset%>" readonly>

<input id="reason" type="text" name="bnReason" size="35" value="" readonly>
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
  #6 (permalink)  
Old Sep 29th, 2004, 10:32
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
<blockquote id="quote" class="ffs">quote:<hr height="1" noshade="noshade" id="quote" />document.getElementById('reason').readonly=true@f alse;<hr height="1" noshade="noshade" id="quote" /></blockquote id="quote">

i've never seen the "@" in javascript.....
not sure. by the way, carefull with the disabled property because disabled elements don't get submitted with the form. if you still want them to be submited you should use readonly instead.

I'm not sure, but change the readonly on a field I think all you have to say is:
document.getElementById('status').readonly = false;
or
document.getElementById('status').readonly = true;

unless the readonly property is in fact, readonly itself, but I think it shoud be fine.


and finally, the link:
<A href="#" onClick="
document.getElementById('status').value = "approved";
document.getElementById('status').readonly = true;
document.getElementById('reason').value = "gimme a reason";
document.getElementById('reason').readonly = true;">
approved</A>


can you put this page on the web so I can look at it. I really think you should be using functions to do this......
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
  #7 (permalink)  
Old Sep 29th, 2004, 10:47
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
ok...
I think that helps me alot, Thanx!
About the @, I put it like that because i am not sure of the truth value of it

So..

TEXT LINK

this code should be working then?
let say that the readonly properties is readonly itself, can I make it
readonly=true; or readonly=false;?

Can I change the readonly textbox if I set the textbox to readonly?
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
  #8 (permalink)  
Old Sep 29th, 2004, 17:14
spinal007's Avatar
Moderator
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,620
Blog Entries: 1
Thanks: 0
Thanked 2 Times in 2 Posts
Send a message via ICQ to spinal007 Send a message via MSN to spinal007 Send a message via Yahoo to spinal007 Send a message via Skype™ to spinal007
if you set a textbox to readonly, you can still use scripting to change the text in it,
I just wasn't sure that once the page is loaded whether you can change the readonly property but you should be able to.
should be fine.......
Last Blog Entry: Random String in Javascript (Apr 21st, 2008)
Closed Thread

Tags
javascript, alert, message

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript warning message finchita JavaScript Forum 5 May 18th, 2008 17:34
Alert Box acrikey JavaScript Forum 4 Mar 25th, 2008 23:23
alert Message messing up sdbdgwood JavaScript Forum 0 Feb 8th, 2008 16:15
javascript alert ycpc55 JavaScript Forum 1 Jan 7th, 2007 02:02
Newbie alert..... pagey Introduce Yourself 11 Sep 2nd, 2006 08:55


All times are GMT. The time now is 09:28.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43