Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Problem with document.field.value

    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.
    Code:
    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

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,081
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    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'
    Last edited by Philip M; 05-03-2006 at 03:12 PM.

  • #3
    New to the CF scene
    Join Date
    May 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    HOLY JE-ZUZ!

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

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •