Results 1 to 6 of 6

Thread: js

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User vlex's Avatar
    Join Date: Jan:2008
    Location: Sofia
    Posts: 340

    js

    ,

    :

    function bla(){

    some source
    }

    ..
    html-a <a href=# onclick="bla('1','2','3');">...</a>

    , , .
    function bla(id){
    for(i=1; i<4; i++) {for (j=0; j<id.length; j++){if (i == id[j]) {document.getElementById(i).style.displa y = 'block';} else {document.getElementById(i).style.displa y = 'none';}}}}

    ? i , j , , style.display = 'block'. , .. , , , .

    .

    ,


    edit:

    , , :
    Code:
    	function toggle()
    	{
    		for(i=0; i<arguments.length; i++) document.getElementById(arguments[i]).style.display = (document.getElementById(arguments[i]).style.display == 'none') ? 'block' : 'none';
    	}

  2. #2
    Mire-x
    Join Date: Apr:2005
    Location: Sofia
    Posts: 763
    ( arguments), , :
    Code:
    <a href=# onclick="bla({'1','2','3'});">...</a>
    ...
    function bla(args)
    {
       for (var i=0, len=args.length; i < len; i++) {
          args[i] ...
       }
    }
    EDIT ( ): { } [ ].
    Last edited by Tarvin; 17th January 2012 at 03:07.
    (10b) || !(10b)

  3. #3
    Registered User vlex's Avatar
    Join Date: Jan:2008
    Location: Sofia
    Posts: 340
    2 - ?

    --------- 19:45 --------- : 19:34 ---------

    dafuq :
    Code:
    function bla(id){
    var i;
    for(i=0; i<id.length; i++) {document.getElementById('result').innerHTML = i + ' element of id[i] is ' + id[i]}}
    Code:
    <a href=# onclick="bla('17','2','3','45','67','13')">bla</a>
    1 element of id[i] is 7
    o.O

  4. #4
    Registered User
    Join Date: Jul:2005
    Location: Sofiq
    Posts: 2,798
    Code:
    function bla(id){
    var i;
    for(i=0; i<id.length; i++) {document.getElementById('result').innerHTML = i + ' element of id[i] is ' + id[i]}
    }
    
    <a href=# onclick="bla('17','2','3','45','67','13')">bla</a>
    '17' ['1', '7'] . js ( ).


    Code:
    function bla(id){
    for(var i=0; i<id.length; i++) {document.getElementById('result').innerHTML = i + ' element of id[i] is ' + id[i]}
    }
    
    <a href=# onclick="bla( [ '17', '2', '3', '45', '67', '13' ] )">bla</a>

  5. #5
    Registered User vlex's Avatar
    Join Date: Jan:2008
    Location: Sofia
    Posts: 340
    - , ) ) , ...

  6. #6
    Mire-x
    Join Date: Apr:2005
    Location: Sofia
    Posts: 763
    Quote Originally Posted by vlex View Post
    - , ) ) , ...
    Code:
    function bla(id) { ... }
    bla('17','2','3');
    id string, '17' ( - '2' '3', , , , "", arguments). id . , : id.length == 2, id[0] == '1', id[1] == '7'.

    ? (), id. , id, arguments.
    Code:
    <a href=# onclick="bla(['17','2','3','45','67','13']);">bla</a>
    ...
    function bla(id)
    {
       var args = arguments;
       var args = id;
       var argsLen = args.length;
       for (var i=0; i < 4; i++) {
          for (var j=0; j < argsLen; i++) {
             if (i == args[j]) {
                document.getElementById(i).style.display = 'block';
             } else {
                document.getElementById(i).style.display = 'none';
             }
          }
       }
    }
    , , . , .
    (10b) || !(10b)

Posting Permissions

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

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |