Announcement

Collapse
No announcement yet.

Homework help, javascript

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

    Homework help, javascript

    Can anybody who knows JavaScript help me with this homework assignment?

    We have to create a form for a purchase order. I have the form itself done. But we have a checkbox that when checked is supposed to put the values from the billing information fields into the shipping information fields, and set the shipping back to blanks if it's unchecked. I've tried doing it the way the teacher's slides show but nothing happens. The book doesn't even mention how to do it. I would think it'd involve onCheck but nothing happens when I use that either. So any help?
    I want that Mulan McNugget sauce, Morty!

    #2
    Re: Homework help, javascript

    Well, I managed to get the info into the fields by using onclick but that doesn't help with getting it cleared back out. I can't get OnCheck or OnUncheck to do anything no matter what I do.
    I want that Mulan McNugget sauce, Morty!

    Comment


      #3
      Re: Homework help, javascript

      I haven't worked with JavaScript forever, so I don't know whether this will apply, but in the Visual Studio programming environments we use something like:

      (in C#) if (CheckBox1.Checked == true)
      {
      (code)
      }

      (in Visual Basic) If (CheckBox1.Checked = True)
      (code)
      End If

      Of course you can also use False. I suppose you could put this under a "Changed" or "Checked" event handler, but if you're using a button to run an event, let's say to fill in the fields or calculate something, that would be the ideal place to put the "If the checkbox is checked then" code.


      How Badly Do You Want It? (VX Ace) is now available for download! - no outside software necessary.

      "I live and love in God's peculiar light." - Michelangelo

      Comment


        #4
        Re: Homework help, javascript

        We're doing the javascript in plain HTML pages so I don't think I could've used C or Visual Basic code but I ended up doing basically that as a function activated by onclick. I don't think that's how we were supposed to do it but it works.
        I want that Mulan McNugget sauce, Morty!

        Comment


          #5
          Re: Homework help, javascript

          Yeah..If oncheck doesn't do anything, initiate a function onclick and then check if the thing is checked in that function in an if statement.

          That sounds like what you did, so, WOO.

          You'll find with internets code, particularly javascript & css, that different browsers act differently with the same code. It blows.
          XBox Live: Alzar2k
          Playstation Network: Alzar2k

          Comment


            #6
            Re: Homework help, javascript

            Well if I would have had internet I probably could have answered this.

            You could probably use onchange instead. Or the other option is to use onclick and use this function.

            onclick = "if (this.checked) { // do stuff } else { // do other thing }"

            This way you make sure that they actually checked it.

            For future reference three very good resource for this are

            www.javascriptkit.com
            www.quirksmode.com
            www.alistapart.com

            But yeah writing cross-browser Javascript is a pain in the ass, especially with events. My chat does a lot of this.

            EDIT (slight correction in wording) :
            And FYI oncheck is not an attribute. Also all attribute names are lower case since well in XHTML, which is what everything will be soon.
            Last edited by thetruecoolness; 04-14-2007, 06:46 PM.
            はじめまして。真(しん)の冷静(れいせい)です。どうぞよろしく。
            http://www.thetruecoolness.com/

            5198-2124-7210 Smash

            Comment


              #7
              Re: Homework help, javascript

              Originally posted by coolness
              And FYI oncheck is not a function. Also all function names are lower case since they are XHTML attributes.
              Dang that teacher and his confusing powerpoint slides.
              I want that Mulan McNugget sauce, Morty!

              Comment


                #8
                Re: Homework help, javascript

                Originally posted by LeChuck View Post
                Dang that teacher and his confusing powerpoint slides.
                Well you teacher might be correct for IE or something, but it's not a cross browser attribute. Which means if you really want a lot of people to use you're site it's useless.

                And you people and your .NET, real coders make their code from scratch .
                Last edited by thetruecoolness; 04-14-2007, 06:48 PM.
                はじめまして。真(しん)の冷静(れいせい)です。どうぞよろしく。
                http://www.thetruecoolness.com/

                5198-2124-7210 Smash

                Comment


                  #9
                  Re: Homework help, javascript

                  But... but... Intellisense is so awesome.

                  "Couch co-op is the only true co-op." Richard of the Cooks.

                  Comment


                    #10
                    Re: Homework help, javascript

                    Well yeah, but lots of other editors have autocomplete as well (Eclipse). Just they don't write the HTML for you behind the scenes using all this overly Object Oriented stuff. But yeah ASP.NET is pretty nice, I just really don't like things that do too much for you, as when you want to do something really customized or complex, it's usually more a hindrance than a help.
                    はじめまして。真(しん)の冷静(れいせい)です。どうぞよろしく。
                    http://www.thetruecoolness.com/

                    5198-2124-7210 Smash

                    Comment

                    Working...
                    X