Results 1 to 6 of 6

Thread: JavaScript and forms

  1. #1
    Join Date
    Oct 2005
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JavaScript and forms

    So i made a script to calculate factorials using 1 to 20. It would display them on the page using document.write.

    What I now want to do is make the start and end number user inputs using 2 forms and a button.

    I'm not completely sure how to do this. Using just the default stuff I would think it's something like

    Code:
    onclick="factorial(document.form1.textfield, document1.form1.textfield2);"
    in the buttons code. This doesn't work. I'm trying to kill 2 birds with 1 stone here. Passing arguments and reading input.

    What am I doing wrong? I am not even sure if the whole document.form1 thing is even close to being correct.

    I'll probably have tons of questions over the next few weeks, so thanks for helpin me out.

  2. #2
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Code:
    onclick="factorial(document.form1.textfield.value, document1.form1.textfield2.value);"
    this maybe ...

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    If this is an <input type="button">, you should use:
    Code:
    onclick="factorial(this.form.elements['textfield'].value, this.form.elements['textfield2'].value);"
    ... although this may be totally wrong since we don't have your code.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Oct 2005
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    that should work, twey. The code is on my laptop that's not connected to the internet, but i believe that's the syntax i was looking for. thanks

  5. #5
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    You can preview it even if you don't have the internet. Anything that's in your protocol browser (I think that's the right term) should be able to be viewed in a browser.
    - Mike

  6. #6
    Join Date
    Oct 2005
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    yes, but what I was saying was I don't have the internet on my laptop so I can't post the code on the forums.

Bookmarks

Posting Permissions

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