Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 12-03-2004, 03:21 PM   #1 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 238
falsepride is on a distinguished road
Unhappy can someone help me debug??

im having major javascript problems and i can't figure it out. my url with the page with the problems is http://skatinsatan.jelloz.net/index....articles&num=1 and the url to the js file is http://skatinsatan.jelloz.net/menu.js. can someone please help me soon

O and by the way, ignore the random crap gibberish on the page, i just need an artivcle actualy set up for that page to display, so i just made some gibberish.

Last edited by falsepride; 12-03-2004 at 07:27 PM.
falsepride is offline   Reply With Quote
Old 12-03-2004, 07:23 PM   #2 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 238
falsepride is on a distinguished road
okay ive been going over my script again and again, and i got the erros out, it works with no errors its not just working how i want it to. i want it to re-enable the submit button if 2 feilds in the form are empty, but its re-enabling it if only the author value isnt empty.
Heres all of my javascript dealing with the form. the function load it excuted onload.
Code:
function load() {
  if(document.forms["pollform"]) {
    document.forms["pollform"].votebutton.disabled = true;
  }
  if(document.forms["commentform"]) {
    document.forms["commentform"].postbutton.disabled = true;
    tick();
  }
}
function tick() {
  calcCharLeft();
  setTimeout("tick()", 300);
}
function calcCharLeft() {
  maxLength = 500;
  if (document.forms["commentform"].body.value.length > maxLength) {
	document.forms["commentform"].body.value = document.forms["commentform"].body.value.substring(0,maxLength);
	charleft = 0;
	clipped = true;
  } else {
	charleft = maxLength - document.forms["commentform"].body.value.length;
  }
  document.forms["commentform"].msgCL.value = charleft;
  if((document.forms["commentform"].author.value.length !== 0) && (document.forms["commentform"].body.length !== 0)) {
    document.forms["commentform"].postbutton.disabled = false;
  } else {
    document.forms["commentform"].postbutton.disabled = true;
  }
  return false;
}
please help soon, until this is fixed i can't finish setting up the rest of my site
falsepride is offline   Reply With Quote
Old 12-05-2004, 09:56 AM   #3 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 238
falsepride is on a distinguished road
Update

if((document.forms["commentform"].author.value.length !== 0) && (document.forms["commentform"].body.length !== 0)) {

i think the problem is in that line. which ever i form field is first whether it be author or body is the deciding factor for if the statement evaluates to true, i only want that to evaluta to true if they're both not empty. that way i have another level of control for flooding, they cant submit an empty form because the button is disabled. its not much of a defense, but the more layers of control you have the better.

can someone please help with the problem
falsepride is offline   Reply With Quote
Old 12-05-2004, 11:18 AM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,706
sde is on a distinguished road
Code:
if((document.forms["commentform"].author.value.length != 0) && (document.forms["commentform"].body.length != 0)) {
'not equal' should be '!=' .. not '!=='
__________________
Mike
sde is online now   Reply With Quote
Old 12-05-2004, 11:35 AM   #5 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 238
falsepride is on a distinguished road
nope, still didnt work, this is a real ball buster. im gonna try a long way of testing, hopefully itll show an answer. ill have an update soon.
falsepride is offline   Reply With Quote
Old 12-05-2004, 11:40 AM   #6 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,706
sde is on a distinguished road
either way, use != instead of !==

also, maybe try to reference a form this way: ( this assumes you have the 'name' attribute set )

document.commentform.author.value.length
document.commentform.body.value.length

also, i just noticed you use .body.length and not .body.value.length ... you need .value in there too
__________________
Mike
sde is online now   Reply With Quote
Old 12-05-2004, 11:46 AM   #7 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 238
falsepride is on a distinguished road
Quote:
Originally Posted by kaeli69

Only IE and Opera let you screw with globals. Gecko makes you actually reference things properly.

document.forms["deleteform"]
or
document.deleteform (less supported)
and thanks for the pick up on the missing value, that was the problem. works fine now. thanks a million times, i was getting so pissed at this script
falsepride is offline   Reply With Quote
Reply

Bookmarks

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 09:16 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting