Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Multiplying values from Input fields

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #176385
    Kingslayer
    Participant

    Hey =),
    first of all im totally new to Javascript so excuse me if the questions seem silly.

    Now to the Problem:

    I have this,
    http://codepen.io/anon/pen/yaFid (anon/pen/yaFid)

    It does what I want. But now i have as in the example Multiple input_fields. They all have a unique ID which i need later on, but is there a way to write a javascript that does the same for all of the fields (Multiplying first with 2nd value and filling it in the 3rd inputfield) so in my example also for the 2nd row. Or do i have to write a javascript function for every time i need it ? (ca. 350 Times…)

    #176422
    Kingslayer
    Participant

    I got alot further now =) The 2 fields are multiplied and written into a new field.
    Than these new fields are added together. Problem here is, that it adds all the fields on the page, not only the ones directly above this certain sumfield. Its hard to describe but i hope the codepen makes it clear what i want to achieve =).

    Here is what i have so far !

    http://codepen.io/anon/pen/kzgmJ

    (anon/pen/kzgmJ) link to the pen as it never shows up for me when i post.

    Hopefully someone can point me in the right direction =).

    Thanks in advance

    #176438
    Kingslayer
    Participant

    makes the value an integer =/ ?!?

    see here:

    http://jsperf.com/valueof-vs-parseint-vs-multiply-by-1/4

    #176575
    Paulie_D
    Member

    Indeed, properly structured HTML leads to, and is arguably, essential to simpler JS/JQ.

    #176628
    Kingslayer
    Participant

    Thank you =) !

    Hmm I wonder what you mean with messy.

    I am really keen on improving my skills, would be nice of you to point it out more specific, so I can improve =)!

    I am always happy to have helpful critique !

    Some of the messy structure might be from “cleaning” it. Because their is alot more to this.

    I am more the Design guy which is my main job as well. So coding is more a hobbie :D.

    But thanks alot =) You guys are super nice !

    #176642
    Kingslayer
    Participant

    I usually use divs and spans, but in this specific case i thought this was the way to go. It’s a series of questionnaires so it is pure data. I build this questionaires and import them into the main website.

    I am still a beginner but i found it alot more challenging to build these with divs and spans, maybe i am not skilled enough :D.

    The responsive part isn’t used here, as these are filled out from a really little group only on desktop computers.

    The part with the hr is just true. I was lazy and it’s not the way to go =/.

    I do not understand this part (my english is not good enough !)

    Thirdly, there are clearly 2 ‘blocks’ of data: the one with 2 questions and the one with 4. Threat blocks as blocks, instead of using them in the same table, split up the tables and use 2 of them. Preferably even place them in a div.

    I wonder if you have an example of a questionaire build with divs and spans.

    PS. On the site you mentioned the logo will disappear behind the image on small screensizes.

    Thank you for all the input and the time you have taken to show me my mistakes !

    #176658
    Paulie_D
    Member

    I usually use divs and spans, but in this specific case i thought this was the way to go

    I think in this case a table is not necessarily the wrong way to go but even then a properly structured table would be required.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.