Jump to content
xisto Community
rantsh

Need A Little Help With Js Calculator and PopUp Menu

Recommended Posts

Hi everyone, The reason I trouble all you today is because when I studied Java I never got the JS section of my book, so this a whole new unexplored world for me.I handle the basics a little, but I'm really screwed up with a couple of assigments that I require, if anyone can help with this I'd really appreciate it.1.- I need a way to format the text that's being inputed on a textbox in such a way that it inserts separators for the thousands values (meaning that as it's being inputed it shows 1.000.000,00 for a million)2.- It's the fashion or something, but now one of my clients wants dynamic or pop-up menus on the navigation bar (you know this nice fashion links that appear when you rollover a button or a text in the nav bar). I've made some research on this and all I find is a big bunch, I mean HUGE scripts, just for a couple of buttons.I was never interested on client side scripting (which is why I never got to the JS section), so if there's anyother way of doing this WITHOUT JS (meaning that if there's an alternative in HTML or something like that) I'd really appreciate it if you mention a source where I could find it. But, if there's not, please guide me on this task that I have no clue on how to start...Thanks in advance...

Share this post


Link to post
Share on other sites

1.- I need a way to format the text that's being inputed on a textbox in such a way that it inserts separators for the thousands values (meaning that as it's being inputed it shows 1.000.000,00 for a million)2.- It's the fashion or something, but now one of my clients wants dynamic or pop-up menus on the navigation bar (you know this nice fashion links that appear when you rollover a button or a text in the nav bar). I've made some research on this and all I find is a big bunch, I mean HUGE scripts, just for a couple of buttons.


I don't think there's a commonly usable way for these actions

1. The Javascript String functions help you in this case.
function givemeseps() { // I assume that the value is in some form field, right? Otherwise you can give the parameter to the function between the ()numba = document.forms['yoursweetform'].yoursweetfield.value;if(isNaN(numba)) return false;numbars = numba.length;if(numbars==7) { // 7 digit number to sumthin like: 1.000.000,00        newnumba = numba.slice(0,1) + "." numba.slice(1,4) + "." numba.slice(4) + ",00";        }else if (numbars==6) { // 6 digit 100.000,00        newnumba = numba.slice(0,3) + "." numba.slice(3) + ",00";        }else if (numbars==5) { // 5 digit 10.000,00        newnumba = numba.slice(0,2) + "." numba.slice(2) + ",00";        }else if (numbars==4) { // 4 digit 1.000,00        newnumba = numba.slice(0,1) + "." numba.slice(2) + ",00";        }else if (numbars==3 || numbars==2 || numbars==1 || numbars==0) { // 100,00 or 10,00 or 1,00 or 0,00        newnumba = numba + ",00";        }document.forms['yoursweetform'].yoursweetfield.value = newnumba;}
You can add more for more digits. I just wrote this function for you, never tested it and I won't cause I got no idea what you are going to use it for. If you describe the situation more closely, I can tell which other cases you have to absorb. no responsibility is taken for the correctness of this information, hehe.
I won't write a hell of a script if you don't tell me where you will use it.. You can try yourself with the String functions of JS. You'll need parseInt() toString() and their little friends to make the trick work.

2. That is because it is a dang complicated thing to make such a script. You have to know how each different browser react. It is not only about if they interprete the functions but also how they handle them. If I was you, I'd try to rip off some professional script. Don't do it yourself if you don't know **** about JS, that would be waste of time. I consider myself firm with the technics (but I'm not a pro) but I could never ever do this properly. Rip off the one from Adobe.com (You'll still need a hell of skills to make it fit your homepage).

greetz,
ruben

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.