Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Javascript HALP

Name: Anonymous 2012-08-16 13:30

function Getunits(){
    var units = document.getElementById('units');
    append = "";
for (count=0; count<=units; count++){
    append = document.getElementById('futureacc').innerHTML = '<input type="text" name="toprovision">';
}
    document.getElementById('futureacc').innerHTML = 'Please provide your Account Number: <input type="text" name="accountnum">';
    document.getElementById('futureacc').innerHTML = append;
}

All I want in life right now is for this script to actually go through the loop and fucking display the form field and not the nothing it currently does.


Please, for the love of whatever you love, help me.

Name: Professional JavaScript Ninja 2012-08-16 13:38

This isn't going to work; getElementById will only ever return one result so there's no point in looping. And a little later you're assigning innerHTML twice etc...

Create a http://jsfiddle.net/ with the form, write down what you want in clear English and I'll show you how it's done.

Name: Anonymous 2012-08-16 13:45

Fuck, I didn't know getElementById worked like that, give me a sec.

Name: Anonymous 2012-08-16 13:51

http://jsfiddle.net/JB2W2/

Alright, so basically: user puts in a number in the "number of units" field, and if they then want the units to be colored, they click yes, which would have an onClick command that would run that script I'm trying to make work.

What's supposed to happen is this: based on the number of units the user types in, the script generates that many fields, WHILE asking for an account number.

That's all.

Name: Anonymous 2012-08-16 14:52

tfw pro js ninja abandons you

Name: Anonymous 2012-08-16 15:19

I've reworked it to this:

function Getunits(){
    var append = "";
    var units = document.getElementById('units');
for (count=0; count<=units; count++){
    append = document.getElementById('futureacc').innerHTML = '<input type="text" name="toprovision">';
}
    document.select.value=append;
}

but it still doesn't do shit.

Name: Anonymous 2012-08-16 15:29

Name: Anonymous 2012-08-16 15:36

>>6

getElementById always returns one element

if you want to select multiple, use getElementsByClassName or TagName

Name: Anonymous 2012-08-16 15:41

>http://jsfiddle.net/aSbJm/

There's no JS in that...

And I do have a dick.

Name: Anonymous 2012-08-16 15:47

>>8

I'll use those, but now I'm wondering if that loop even does anything.

Name: Anonymous 2012-08-16 15:55

Not enough jQuery

Name: Anonymous 2012-08-16 17:16

>>11

Not enough competence is more like it.

Name: Anonymous 2012-08-16 17:59


  CC      net/core/fib_rules.o

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List