PDA

View Full Version : Syntax Error


tripwater
06-29-2005, 06:57 PM
Hello,

I copied and pasted below the results of viewing source on one of my pages. It gets built dynamically with php and MYSQL.

I am currently getting an syntax error on line 98. I have no idea what it is. THe first time I visit the page, it is fine, but on the onchange event that reloads the page and passes back a query string for one of my queries, I then get the error.


<html>
<head>
<title>NizeX Project Management System</title>
</head>
<style type="text/css">

h1{color:black; font-size:18pt; text-align:left; font-family:arial,sans-serif}

h2{color:black; font-size:14pt font-family:arial,sans-serif font-weight:bold}

h3{color:black; font-size:10pt font-family:arial,sans-serif}

h4{color:black; font-size:9pt font-family:arial,sans-serif}

h5{color:black; font-size:12pt font-family:arial,sans-seriff}

.menu {color:white; font-size:12pt; text-align:center;
font-family:arial,sans-serif; font-weight:bold}

td {font-size:10pt; font-family:arial,sans-serif;}

p {color:black; font-size:10pt;
font-family:arial,sans-sarif}

font {color:black; font-size:9pt; text-align:left;
font-family:arial, sans-serif; font-weight:bold}

a {
color: 697bc7;
font-size:10pt;
font-family:arial,sans-sarif;
text-decoration:none;
}

a:hover {
color: red;
font-size:10pt;
font-family:arial,sans-sarif;
text-decoration:none;
}


a.colorchange{
color: 000000;
font-size:10pt;
font-family:arial,sans-sarif;
text-decoration:none;
}

a:hover.colorchange {
color: FFFFFF;
font-size:10pt;
font-family:arial,sans-sarif;
text-decoration:none;
}


body {font-face:arial,sans-sarif font-size:10pt; background:#c9d5e7}

ul {font-face:arial,sans-sarif font-size:10pt}


li {color:black; font-size:10pt;
font-family:arial,sans-sarif}

b {color:black}

</style>
<script language="JavaScript" type="text/javascript">

function TheFormCheck()
{
// set var checkbox_choices to zero
var checkbox_choices = 0;

// Loop from zero to the one minus the number of checkbox button selections
for (i = 0; i < document.tester.elements.length; i++)
{
if(document.tester.elements[i].type == 'checkbox')
if (document.tester.elements[i].checked)
{
checkbox_choices = checkbox_choices + 1;
}
}


}



<!--this function tells our select options to advance to the page assigned, on the onchange event-->

function doSel(obj)
{
for (i = 0; i < obj.length; i++)
{
if (obj[i].selected == true)
eval(obj[i].id);//THIS SHOULD BE LINE 98
}
}





function CheckAll()
{
for (var i = 0; i < document.tester.elements.length; i++)
{
if(document.tester.elements[i].type == 'checkbox')
document.tester.elements[i].checked =!(document.tester.elements[i].checked);

}
}

</script>

<body>
<form name="tester" method="post" action="../admin/assign_tester_task_submit.php" onSubmit="return TheFormCheck()";>
<table width=80% border=0>
<tr valign=top>
<td colspan=2>
Check the boxes beside the tester(s) you would like to assign to this task or select a preset testing group.
<br><br>
</td>
</tr>
<tr valign=top>
<td>

<b>Testing Groups</b><br>

<select name=group onchange="doSel(this)">
<option value ="" id="location.href='../main/assign_tester_task.php'"><--Group--><option value =9 id="location.href=../main/assign_tester_task.php?id=9" selected>Joe_and_Lyss<option value =7 id="location.href=../main/assign_tester_task.php?id=7">Main<option value =8 id="location.href=../main/assign_tester_task.php?id=8">Top</select><br><br>
</td>
</tr>
<tr valign=top>
<td width=275>
<input type=submit name=submit value="Assign to task"><br>
<b><a href="javascript:void(0)" onClick="CheckAll();">Toggle All</a></b><p>

<b>Testers</b><br>

<input type=hidden name=count value="10">
<input type=hidden name=adding value=yes><input type=checkbox name=0 value=12>Brian <br><input type=checkbox name=1 value=11>Chris <br><input type=checkbox name=2 value=17 checked>Elyssa <br><input type=checkbox name=3 value=35>Eric <br><input type=checkbox name=4 value=6>Glenn <br><input type=checkbox name=5 value=10>Jeff <br><input type=checkbox name=6 value=8>Jim <br><input type=checkbox name=7 value=9 checked>Joe <br><input type=checkbox name=8 value=22>test<br><input type=checkbox name=9 value=1>Tim <br> <p><input type=submit name=submit value="Assign to task"><br>
</td>
</tr>
</table></form>
</body>
</html>

Thanks for any help with this.

Burgerking63
06-29-2005, 07:08 PM
Surround all your If statements with { }
ex)

if (form.radio1.checked == true) {
yadayadayada; }

If you still have errors, then your coding is wrong somewhere else. Try to keep all your code aligned left, then tabbed from there accordingly, makes it easier to follow and read. Avoid strange return spacing as well

tripwater
06-29-2005, 07:10 PM
Is this really necessary? I do this all the time. I do this all over many different sites and do not get errors.

I have another page that does the same thing and I am not getting this syntax error.

Try to keep all your code aligned left, then tabbed from there accordingly, makes it easier to follow and read. Avoid strange return spacing as well

Like I said in the original post I copied and pasted from the view source...

Well I guess this means the error is somewhere else then. Can someone else help me then please?

Willy Duitt
06-29-2005, 07:29 PM
http://www.webdeveloper.com/forum/showthread.php?p=394876#post394876

tripwater
06-29-2005, 07:36 PM
And your point is? Are both these sites supposed to be the same? Sorry but I don't just rely on one resource...

Thanks for your help though my problem is solved :rolleyes:


You know I come here for help, not for people to point out useless things that have nothing to do with what I posted.

Can someone else please help?

Willy Duitt
06-29-2005, 07:45 PM
And your point is? Are both these sites supposed to be the same? Sorry but I don't just rely on one resource...

Thanks for your help though my problem is solved :rolleyes:


You know I come here for help, not for people to point out useless things that have nothing to do with what I posted.

Can someone else please help?

blah blah blah...

We are here to help each other... NOT to be at your beck and call...
If you found the solution a good citizen would share the solution with everyone... The reason I posted the link to the other site is contained in the above... If you would like, I could sell you a clue... :D

.....Willy

tripwater
06-29-2005, 07:52 PM
Dude, I am at a loss. I came here for help. I never asked anyone to be at my beck and call, I have not found the solution or I would not still be here talking to you. I do not understand this pretentious approach to helping someone.

The answer is not in the above post. If you know what the problem is with my code, I am all ears. I personally am bored with this conversation and too busy to continue it with you any longer if this all the help you can bring

Is anyone else bothered by the fact that all I did was post a problem on more than one site to get quicker results? I really hope not. This is ridiculous. What part of the original post said BE AT MY EVERY BECK AND CALL?

Willy Duitt
06-29-2005, 07:54 PM
Dude, I am at a loss. I came here for help. I never asked anyone to be at my beck and call, I have not found the solution or I would not still be here talking to you. I do not understand this pretentious approach to helping someone.

The answer is not in the above post. If you know what the problem is with my code, I am all ears. I personally am bored with this conversation and too busy to continue it with you any longer if this all the help you can bring

You should try to read what you write... :rolleyes:

Thanks for your help though my problem is solved :rolleyes:

CLUE: Problem is solved indicates that a solution was found...

tripwater
06-29-2005, 07:58 PM
ok, I will give you that, but that was supposed to be sarcasm

But if you read just under that I said

"Can someone else please help?"

It is not solved. And the link to the other post seemed like you were just doing that to be a jerk. If you were only doing that to give a link to a possible answer in the future then I appologize

tripwater
06-29-2005, 08:00 PM
I use these forums alot because I am not the best at JS. Everyone I have ever dealt with in this site has always been great. I would like to keep a good relationship here if possible. All I am looking for is someone that can point out why I am getting this error please.

Thanks

nikkiH
06-29-2005, 08:07 PM
eval(obj[i].id);//THIS SHOULD BE LINE 98

What were you trying to do there? Eval usually returns something.
And eval generally sucks. I bet there's a better way to do what you were trying to do.

Oh, wait, now I see.
There is definitely a better way to do that -- you can't use eval like that.
It's a jump menu.

Here ya go.

function jump (loc)
{
if (loc)
{
self.location.href = loc;
}
}


<select name="group" onchange="jump(this.options[this.selectedIndex].value)">
<option value ="../main/assign_tester_task.php">nothing</option>
<option value ="../main/assign_tester_task.php?id=9" selected>Joe_and_Lyss</option>
<option value ="../main/assign_tester_task.php?id=7">Main</option>
<option value ="../main/assign_tester_task.php?id=8">Top</option>
</select>

tripwater
06-29-2005, 08:09 PM
THanks, I will try that. I got the code from a previous forum posting.

It works in Firefox but I get the errors in IE(my old code that is)

tripwater
06-29-2005, 08:40 PM
Ok after looking at your code you posted, I have a question.

Keep in mind I do not know a great deal about JS so bear with me. I see you set the value = to the URL for the jump menu. I need the value to actually = the GroupID that it is set to in my code. so when I post to the next page, I can have it to submit to my DB. THat is why I put the URL in the ID so I would still be able to use the value for that. Is there a way to accomplish this?

See the URL in the jump box is the same page as the jumpbox. By calling the same page and passing it a query string of their choice it affects my query below jump box. If that makes sense

Also I am using this same function on another page and it works and does not get errors. I am not sure why but it does.

Thank you again for your help

nikkiH
06-29-2005, 08:48 PM
The ID for the PHP page was coded right in the value, as you had it.
Instead of trying to eval the ID of the option to change location.href, I just sent location.href the place to go to.

<option value ="../main/assign_tester_task.php?id=9">Joe_and_Lyss</option>

(what you had was:
<option value =9 id="location.href=../main/assign_tester_task.php?id=9" selected>Joe_and_Lyss
which isn't even valid html, so I don't know why it worked either LOL)

This should work fine. When the user chooses an option, the document location changes to that URL (the value). Give it a shot and see.

tripwater
06-29-2005, 09:14 PM
Thank you very much. That did it. :D