View Full Version : refresh - to the bottom of the page

11-01-2004, 01:53 AM
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! :thumbsup:

11-01-2004, 11:12 PM
If you're using javascript to do your calculations as alluded to in the previous thread (http://www.codingforums.com/showthread.php?t=46761) 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?

11-04-2004, 04:51 AM
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.

11-04-2004, 04:47 PM
...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,

<button onclick="update()">Update Total</button>

...or like this with the submit button onsubmit:

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

11-04-2004, 08:53 PM
hmm. . .

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

<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,

11-04-2004, 09:13 PM
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.


11-04-2004, 09:20 PM
I see, that's pretty sweet, learn something new every day. Can add images to them etc. Neat!


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum