Welcome to WebmasterWorld Guest from 54.160.163.163

Forum Moderators: open

Message Too Old, No Replies

Javascript error. Can anyone see where I'm going wrong?

     

fintan

9:26 am on Jun 13, 2003 (gmt 0)

10+ Year Member



<script language="JavaScript1.2" type="text/JavaScript">
<!--

function checkForm(){
//variable
var checkbox = document.forms[0].call_cleared.checked;
var category = document.forms[0].elements[0].options[document.forms[0].elements['cat'].selectedIndex].value
//variable

//conditional statment

if(category=="16" && checkbox == true){
alert("You must assign a category")
return false;
}
else{email() //Call function within function
return true;
}

}

function email(){

//variables
var checkbox = document.forms[0].call_cleared.checked;
var selected = document.forms[0].itstaff.selectedIndex;
var val = document.forms[0].itstaff.options[selected].value;
//variables

//conditional statments

//Checking to see if call is assigned
if(val == "16"){
return false;
}
//If call is closed send closure email
else{
if(checkbox == true){
window.open('/helpdesk/email/sendclosed.asp?callID=<%=(rscalls.Fields.Item("callID").Value)%>','','width=180,height=50','top=5000,left=5000')
}

//If call is open send email
else if(checkbox == false){
window.open('/helpdesk/email/sendnotice.asp?callID=<%=(rscalls.Fields.Item("callID").Value)%>','','width=180,height=50','top=5000,left=5000')
}
}

//conditional statments end

//-->
</script>

<form action="<%=MM_editAction%>" method="POST" name="form1" onSubmit="return checkForm()">

BlobFisk

9:52 am on Jun 13, 2003 (gmt 0)

WebmasterWorld Senior Member blobfisk is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Hey Fintan,

What exactly are you seeing wrong on your page?

[quote]
'top=5000,left=5000'
[/top]

These are very, very high - the popup will open well offscreen.

In your var category line, put a ";" at the end of the line, and also after emaail() here:

else{email() //Call function within function

A description of what seems to be going would be a big help.

fintan

10:21 am on Jun 13, 2003 (gmt 0)

10+ Year Member



Sorry

Ok We have two dropdown lists & one checkbox. Each fuction when on its own works fine. Never mind the asp in for the moment.
Basically in dropdown list "A" undetermined is an option and it has a value of 16. So if list "A" is undetermined and the checkbox is ticked don't process the form.

Now the second dropdown list "B" unassigned has a value of 16 as well. If "B" is unassigned don't send an email. But if it is assigned send email. It also checks to see if the checkbox is ticked which then decides the type of email to send.

Now what I want to do is bring them together.

ShawnR

11:42 am on Jun 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I can see a whole bunch of things that I don't like style-wise (probably just my preference ... ;) But it would be better to understand the symptoms, rather than getting you to chase your tail tweaking things but ignoring the main problem.

fintan

11:58 am on Jun 13, 2003 (gmt 0)

10+ Year Member



Can you see where I went wrong. I need the alert to work first then the email decision.

korkus2000

12:08 pm on Jun 13, 2003 (gmt 0)

WebmasterWorld Senior Member korkus2000 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



fintan I think we can help if you could give us a little more info:

1. What happens when you run this?
2. What do you not like about that?
3. What do you want it to do?

ShawnR

12:15 pm on Jun 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Like I said, I can see a whole lot of problems... Not sure which will be the thing causing a real problem vs just poor style. For example, BlobFisk pointed out you left out some semicolons. Well, that is true, but most browsers are forgiving, so that is a problem, but probably not the problem.

So it really would help if you can explain the symptoms you are seeing. What happens in your browser?

But if I had to take a guess, I think the problem is here:


//If call is closed send closure email
else{
if(checkbox == true){

should be


//If call is closed send closure email
else
if(checkbox == true){

(Or another way to fix it would be to add another } just before

//conditional statments end

//-->
</script>

Shawn

grahamstewart

12:21 pm on Jun 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think Shawn has solved your problem, but as an aside...
I hope you are checking the form dat on the server side as well and not just relying on this script to validate your form.

Because a) around 10% of users have javascript turned off and b) someone is bound to try sending you dodgy data anyway to see what happens.

fintan

12:54 pm on Jun 13, 2003 (gmt 0)

10+ Year Member



Its on an intranet site so dodgy data isn't something I have to worry about. Thanks for that I been staring at it for so long now I was starting to lose touch with reality. Oh I could make it neater but I need it done yesterday. Thanks again

fintan.

ShawnR

10:41 am on Jun 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"...on an intranet site so dodgy data isn't something I have to worry about..."

I put the above sentence through a validator, and the result I got back is:

line 1, char 25: Semantic error: 'so' used to imply inference which is neither analytically nor synthetically rational. Hence by Hume's fork the statement is classified as 'non-sense'.

Good that you don't have to worry about it; makes things that much easier. ;) But just make sure that is a valid assumption.

Shawn

(PS. Don't get offended by the output of the validator. "non-sense" doesn't neccesarily mean 'BS'; it could just mean "information that can't be verified using your 5 senses" (hence non-sense data).)

g1smd

9:36 pm on Jun 14, 2003 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Having it on an Intranet probably makes it more vunerable...

vunerable to childish people simple playing about, and vunerable to that disgruntled employee out to cause lots of damage on their last day.

Check it. Secure it.

fintan

8:58 am on Jun 16, 2003 (gmt 0)

10+ Year Member



Its for my IT department and its in there interest not to put in dodgy data.

ShawnR

12:34 pm on Jun 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Don't mean to labour the point; all I want to do is point out the issue...

It may not be deliberate. IT people are precisely the sort of rebelious lot who decide to turn off javascript in their browser because they are sick of pop-ups or because they are better educated about spy-ware/scum-ware. If you are going to rely solely on javascript for form validation, then I suggest you use javascript to submit the form, and have the form's html action be null or point to a static html page which says 'sorry, you need to turn on javascript'. That way you force people who want to submit the form to turn on javascript.

Shawn

fintan

1:45 pm on Jun 16, 2003 (gmt 0)

10+ Year Member



Oh I get your point. I know if I was doing something on the internet I'd have to do it another way. Its just that in the environment that I'm in I'm lucky that I don't have to worry about such things. Its a small IT department.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month