SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Add text

  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2012
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Add text

    Anyone help me to make this?

    Code:
    http://imgur.com/a/mRjm5#0
    JS + HTML:
    Code:
    http://jsbin.com/ojilut/1/
    Thanks Guys

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,078
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    I don't really want to make it for you, but i don't mind helping you.
    What part are you stuck on?

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2012
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Pullo View Post
    I don't really want to make it for you, but i don't mind helping you.
    What part are you stuck on?
    Code:
    function count(){
    var numero = 0;
    var val0 = document.getElementById("idvideo1").value;
    
    
    for (var i=0;i<1;i++) {
    	if(eval('val'+i) != "") {  
    		numero ++;
    		}
    	}
    alert(numero);
    //numero = 6 - numero;
    //return numero;
    //alert(numero);
    }
    }
    Code:
    function gerar() {
    var cont = '';
    document.getElementById("cod").value = "";
    while (numero--) {
         cont += "Hello ";
         document.getElementById("cod").value += cont;
    }
    document.getElementById("cod").value += cont;
    }
    How send the value number for function "gerar"? Thanks!

  4. #4
    SitePoint Enthusiast
    Join Date
    Dec 2012
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Edit:

    Problem solved for now! Thanks for your availability.

  5. #5
    SitePoint Enthusiast
    Join Date
    Dec 2012
    Posts
    61
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have one problem...I Have 2 variables (val1 and val2), when i insert data in two inputs (val1 and val2), alert = 2, when i insert only data in one variable don't display any alert, nor execute the rest of the code. Whats wrong?

    Code:
    http://jsfiddle.net/MyNameIsJoe/shnqu/
    I did other example and works good...

    Code:
    http://jsfiddle.net/MyNameIsJoe/L7ySS/
    (in jsfiddle doesn't work)

  6. #6
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,078
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Hi,

    I'm sorry, but I cannot reproduce your problem.
    The code didn't work in JSFiddle, but I copied it to my PC and everything works as expected.

    It seems that val1 references this:

    HTML Code:
    <b>name:</b> <input type="text" id="idvideo1" name="idvideo1">
    and that val2 references:

    HTML Code:
    <b>Favorite Color:</b> <input type="text" id="idvideo11" name="idvideo1">
    If I enter "Pullo" into the name field and leave the colour field blank, I see an alert saying "1" and the following is output to the text area:

    Code:
    11111 Pullo 1111  1111
    If I enter "Blue" into the colour field and leave the name field blank, I see an alert saying "1" and the following is output to the text area:

    Code:
    22222 Blue 22222  22222
    If I enter both "Pullo" and "Blue" into the respective fields I see an alert saying "2" and the following is output to the text area:

    Code:
    11111 Pullo 1111  1111 
    22222 Blue 22222  22222 
    11111 Pullo 1111  1111 
    22222 Blue 22222  22222
    I'm presuming that is what it should do.

    Edit: I just noticed that the two input fields have the same name attribute. This is not good.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •