Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › Can't Call Function in Javascript *EDIT* I fixed it
New Posts  All Forums:Forum Nav:

Can't Call Function in Javascript *EDIT* I fixed it - Page 2

post #11 of 15
Thread Starter 
Quote:
Originally Posted by MakubeX View Post

Are you actually trying to start a company or is this just for practice?
Actually starting the company, this is just the startup website though, I will probably be paying someone to do the final version, or pay them to do part of the final version and I do the rest.
Black Jarvis V1.9
(21 items)
 
Mazdaspeed6
(18 items)
 
 
  hide details  
Reply
Black Jarvis V1.9
(21 items)
 
Mazdaspeed6
(18 items)
 
 
  hide details  
Reply
post #12 of 15
Quote:
Originally Posted by ADHDadditiv View Post

Actually starting the company, this is just the startup website though, I will probably be paying someone to do the final version, or pay them to do part of the final version and I do the rest.
Ok, I see. The final version will probably have to be remade from scratch. Have you considered using a CMS to build your initial website? It might make it easy enough to use a database, and ultimately save you time and effort.
post #13 of 15
Try making an absolute reference to the ID... you're referencing it from the previous functions, but if they aren't being called within that function, you don't have a valid reference to the object.
Code:
<script type='text/javascript'>
function systemTotal() {
        var ram = document.getElementById('part_RAM').value;
        var cpu = document.getElementById('part_CPU').value;
        var total = parseInt(ram, 10) + parseInt(cpu, 10);
        document.getElementById('cart_Total').value = total;
}
</script>

Since you are using 'var' in the earlier functions they are considered local to the function. You can either omit this in which case it will look for a value 'up the chain' until it reaches the global scope and if it still doesn't find a value it will create the variable in the global scope. Otherwise, as I stated earlier, since you're not using a dynamic language, you can just use an absolute reference wrapped in single quotes - because the variable are simply referencing the ID itself as a text string and not the DOM Object for more complex operations.

When in doubt... and certainly until you get a handle on basic HTML and JavaScript syntax and interactions - you should keep it very simple and make everything direct. Then as you become more comfortable you can move to optimization and a more truly OOP methodology.
Quote:
Originally Posted by MakubeX View Post

Ok, I see. The final version will probably have to be remade from scratch. Have you considered using a CMS to build your initial website? It might make it easy enough to use a database, and ultimately save you time and effort.

It's been suggested before - he's determined to do it this way rather than get an off the shelf package. He's using goDaddy which has an opensource php cart API which can be installed to hosts, but I think it's more of a learning experience at this point. I however, completely concur with both of your suggestions! wink.gif
Edited by DiGiCiDAL - 5/20/13 at 9:46pm
post #14 of 15
Quote:
Originally Posted by DiGiCiDAL View Post

It's been suggested before - he's determined to do it this way rather than get an off the shelf package. He's using goDaddy which has an opensource php cart API which can be installed to hosts, but I think it's more of a learning experience at this point. I however, completely concur with both of your suggestions! wink.gif

Well as a learning as experience I say great! As a production website I say good luck sir, you're going to need it! tongue.gif
post #15 of 15
Hey, OCN is a community, opn for everyone tongue.gif

You should change the title of the thread bak to the original so people can find it easier for future reference.

Posting how you fixed it should also be great for both us and lurkers thumb.gif
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Web Coding
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › Can't Call Function in Javascript *EDIT* I fixed it