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 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Oct 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    refresh - to the bottom of the page

    Hi guys,

    I have created a form, at the bottom of the form is a button which updates the total price which is also displayed at the bottom of the form. The problem is, when I click the button it refreshes and by default goes to the top of the page. What can I use to program the button to update the totals and refresh to the bottom of the page. Any web tutorials, books, links, or sample code would be much appreciated. Thanks for the help!

  • #2
    Regular Coder
    Join Date
    Jul 2004
    Location
    mile high city
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you're using javascript to do your calculations as alluded to in the previous thread there probably shouldn't be a refresh taking place.

    It sounds like your button may be an input type="submit" when you don't actually want to submit any form data. How about the code you're working with?
    Computer, kill Flanders... Did I hear my name? My ears are burning...
    Good start. Now finish the job.

  • #3
    New to the CF scene
    Join Date
    Oct 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Your right I'm using

    <INPUT type="submit" name="mybutton" value="Click me!">

    I'm pretty new at this and just assumed that was my best option.

    What should I be using instead?

    Thanks for the help.

  • #4
    Regular Coder
    Join Date
    Jul 2004
    Location
    mile high city
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ...at the bottom of the form is a button which updates the total price...
    If the update is being done with javascript and not server side your button should like something like this, where your function is triggered onclick,

    Code:
    <button onclick="update()">Update Total</button>
    ...or like this with the submit button onsubmit:

    Code:
    <input type="submit" value="Update Total" onsubmit="update();return false;">
    The button element in the first bit of code doesn't perform any action on its own, versus the input type="submit" which will try to submit your form data unless its default action is cancelled with return false.

    Either way, your javascript function and the event handler calling it should be part of the button code. Hope that helps.

    And a friendly reminder that you'll get quicker and more informed responses if you post the relevant code with your original question.
    Computer, kill Flanders... Did I hear my name? My ears are burning...
    Good start. Now finish the job.

  • #5
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    hmm. . .

    Code:
    <button onclick="update()">Update Total</button>
    That's new to me, I've never known of a button tag. Is that proper?

    I would use:

    Code:
    <input type="button" value="Update Total" onclick="update()" />
    If it is proper, that's kinda cool for styling by element, I often want my inputs to have different styles than my buttons this way no class has to be specified.

    Just curious,
    Basscyst
    Helping to build a bigger box. - Adam Matthews

  • #6
    Regular Coder
    Join Date
    Jul 2004
    Location
    mile high city
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've never used button myself, but apparently you can add content unlike an input type="submit". You can also add type="submit" to the button to make it act like an input type="submit" and isolate it in your css by element rather than class if necessary.

    http://www.w3.org/TR/REC-html40/inte...ms.html#h-17.5
    Computer, kill Flanders... Did I hear my name? My ears are burning...
    Good start. Now finish the job.

  • #7
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    I see, that's pretty sweet, learn something new every day. Can add images to them etc. Neat!

    Basscyst
    Helping to build a bigger box. - Adam Matthews


  •  

    Posting Permissions

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