Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 12th, 2007, 12:18 PM   #1
bogeypepsi
Newbie
 
Join Date: Mar 2007
Posts: 1
Rep Power: 0 bogeypepsi is on a distinguished road
Javascript debugging

I hate javascript debugging because it is so non specific when you have an error... Anyway here is my script I am having trouble with... (I am getting an error saying I am "missing ; before statement" Please Help

onclick="
if(document.form2.shipfax.value=='Shipper Fax')
{
document.form2.shipfax.value='Shipper Fax <--- REQUIRED';
document.form2.shipfax.style.color='red';
document.form2.shipfax.onfocus='
if(document.form2.shipfax.value=='Shipper Fax <--- REQUIRED')
{
document.form2.shipfax.value='';
document.form2.shipfax.style.color='black';
};';
document.form2.shipfax.onblur='
if(document.form2.shipfax.value=='')
{
document.form2.shipfax.value='Shipper Fax <--- REQUIRED';
document.form2.shipfax.style.color='red';
};';
};"
bogeypepsi is offline   Reply With Quote
Old Mar 12th, 2007, 1:14 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Please investigate the use of code tags, in order to retain your formatting and indentation. You'll find this mentioned in the rules/faq and the "How to Post a Question" thread.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Mar 12th, 2007, 1:49 PM   #3
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
It looks like you have quotes inside your quotes, so to speak, and some odd placement of semicolons. Strictly speaking, though, you shouldn't need to quote any code at all.

Now, it appears as if you want all required values to show up in red, and then to change to black when the user clicks on them. However, you only seem to be doing this for one field, and it seems possible there might be several required fields. Could you perhaps explain exactly what it is you're trying to do? You might be going about it the hard way.

For reference, here's a version of your code that uses functions, rather than strings of executable code. However, I think that there might be an easier way to do what you're trying to achieve.

javascript Syntax (Toggle Plain Text)
  1. function focused() {
  2. if(document.form2.shipfax.value == 'Shipper Fax <--- REQUIRED')
  3. {
  4. document.form2.shipfax.value = '';
  5. document.form2.shipfax.style.color = 'black';
  6. }
  7. }
  8.  
  9. function blurred() {
  10. if(document.form2.shipfax.value == '')
  11. {
  12. document.form2.shipfax.value = 'Shipper Fax <--- REQUIRED';
  13. document.form2.shipfax.style.color = 'red';
  14. }
  15. }
  16.  
  17. function clicked() {
  18. if(document.form2.shipfax.value == 'Shipper Fax')
  19. {
  20. document.form2.shipfax.value = 'Shipper Fax <--- REQUIRED';
  21. document.form2.shipfax.style.color = 'red';
  22. document.form2.shipfax.onfocus = focused;
  23. document.form2.shipfax.onblur = blurred;
  24. }
  25. }
Arevos is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hidden unless Javascript enabled? Writlaus JavaScript and Client-Side Browser Scripting 3 Apr 25th, 2006 10:52 PM
Debugging JavaScript? Klipt JavaScript and Client-Side Browser Scripting 4 Dec 16th, 2005 1:47 PM
HTML page not reading external Javascript file aznluvsmc JavaScript and Client-Side Browser Scripting 9 Nov 21st, 2005 9:17 PM
Curious about Debugging linuxpimp20 Other Programming Languages 7 Sep 9th, 2005 8:55 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:11 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC