...

View Full Version : Problem with document.field.value



JCompo
05-03-2006, 03:50 PM
Hi guys, I'm new to Javascript and am having a problem with the information found in a document value. I am doing code maintenance on the website for our company and am having difficulties debugging this one page. We use a mixture of .asp and javascript.

I have several drop down boxes. OnChange, a function is called to verify that data in previous drop downs are valid. I am just trying to debug it at this moment and alert() me of a drop down's value.


function ResetFields(chgfld) {
if (chgfld == 'Year') {
if (document.frmEditVeh.lstVehTyp.value == 'nada') {
var jason = document.frmEditVeh.1stVehTyp.value;
alert("Please specify this vehicle's type." + jason);
document.frmEditVeh.lstYrModl.value = 'nada';
document.frmEditVeh.lstVehTyp.focus();
} else { ...


I've stuck in there the var jason part so I can see what is in that value but it now crashes when calling that function whether or not the 'nada' valued select option is chosen. If I take out the var jason line and the +jason out of the alert box, it works fine.

Firefox is giving me the following errors concerning this:

ResetFields is not defined <---when something other than 'nada' chosen

ResetFields is not defined <---when 'nada' chosen
missing ; before statement
var jason = document.frmEditVeh.1stVehTyp.value;

*The red 1 is where Firefox points to for the missing ;

I thank you for your time,
Jason

Philip M
05-03-2006, 04:06 PM
An old pitfall - you have confused figure 1 with lower case l

function ResetFields(chgfld) {
if (chgfld == 'Year') {
if (document.frmEditVeh.lstVehTyp.value == 'nada') {
var jason = document.frmEditVeh.1stVehTyp.value;
alert("Please specify this vehicle's type." + jason);
document.frmEditVeh.lstYrModl.value = 'nada';
document.frmEditVeh.lstVehTyp.focus();
} else { ...


But

if (document.frmEditVeh.lstVehTyp.value == 'nada') {
var jason = document.frmEditVeh.lstVehTyp.value;

surely this equates to var jason = 'nada'

JCompo
05-03-2006, 04:18 PM
HOLY JE-ZUZ!

I am now the laughing stock of my little cubicle microcosm. :rolleyes:

I thank you sir. That has just solved every problem I was having with that page.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum