Web Analytics Made Easy -
StatCounter Error: Null or Not an object - CodingForum

Announcement

Collapse
No announcement yet.

Error: Null or Not an object

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error: Null or Not an object

    I am getting an error on IE with this java script which is saying:
    d.value is null or not an object
    where d is a text box value.

    Please look at the source code of:
    http://www.pitt.edu/~play
    Basically I am trying to use the JSE Internal Search engine here(got from http://www.javascriptkit.com/script/...se/index.shtmt) and I am getting the error for the value of textbox for the search.

    Could anyone help please?

  • #2
    That's a lot of code to look through, so I'll just say that a textbox value doesn't have a value property. The textbox element does.
    So, say you have
    <input type="text" name="d" value="here">

    You can do d.value, not d.value.value.
    If you're passing the .value to a function, pass the object (either full reference or "this", depending on where it is, how called, etc) instead.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

    Comment


    • #3
      Try this
      Code:
      <form action="#" method="post">
      <input type="text" name="d" size="10">
      <input type="button" value="Go" onclick="search_form([b]this.form[/b])">
      </form>
      The script was looking for a variable but you never defined one in the onclick.
      Last edited by _Aerospace_Eng_; Aug 1, 2005, 04:56 PM.
      ||||If you are getting paid to do a job, don't ask for help on it!||||

      Comment


      • #4
        Thank you for the reply.
        It works now.
        The only concern I have now is that when I changed the input type from button to submit, it doesnt seem to work. I want to do this because i want the form to be submitted even when the enter key is pressed, and not just by clicking on the button.

        Comment


        • #5
          I didn't suggest that yesterday because that wasn't what you asked. Use this for the script
          Code:
          <script type="text/javascript">
          // ---------- script properties ----------
          var results_location = "results.html";
          // ---------- end of script properties ----------
          function search_form(jse_Form) {
          	if (jse_Form.d.value.length > 0) {
          		document.cookie = "d=" + escape(jse_Form.d.value);
          		window.location = results_location;
          	}
                  return false;
          }
          
          </script>
          And this for the form
          Code:
          <form action="#" method="post" onsubmit="return search_form(this.form)>
          <input type="text" name="d" size="10">
          <input type="submit" value="Go">
          </form>
          ||||If you are getting paid to do a job, don't ask for help on it!||||

          Comment


          • #6
            http://www.pitt.edu/~play/index1.html
            This is where I have done as you said.
            But when i submit hte form, it says, resource not allowed. http error 405

            Comment


            • #7
              Oops sorry, that was my fault left out a quote, and it should be this, not this.form since its already in the form tag.
              Code:
              <form action="#" method="post" onsubmit="return search_form(this)">
              <input type="text" name="d" size="10">
              <input type="submit" value="Go">
              </form>
              ||||If you are getting paid to do a job, don't ask for help on it!||||

              Comment

              Working...
              X