Results 1 to 3 of 3

Thread: parameters in script

  1. #1

    Thread Starter
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    parameters in script

    hi to all good day.
    how can i pass a parameter in a function?
    what i want is i just want to pass a parameter in a function and call the function on my onkeypress of textbox.
    i have this code and it seems won't work.
    pls. help im very new in this thing..
    PHP Code:
    <form>
        <
    input type="textbox" name="textbox1" id="txttel" onkeypress="keydown(event,'txtname')">
        <
    input type="textbox" id="txtname" onkeypress="keydown(event,'txtadd')">
        <
    p>
        <
    input type="textbox" id="txtadd" onkeypress="keydown(event,'txthome')">
        <
    p>
        <
    input type="textbox" id="txthome" >
        </
    form>
    <
    script>
        
    document.getElementById("txttel").focus();
    </
    script>
    <
    script>
        function 
    keydown(e,var s){
        if (!
    e) var window.event;
        if (
    e.keyCodecode e.keyCode;
        else if (
    e.whichcode e.which;
        if (
    code==13){
        
    document.getElementById("s").focus();
        }
        }
    </
    script
    thanks in advance guys..more power.

  2. #2
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552
    try this mate
    PHP Code:
    <form action="">
    <
    table>
        <
    tr>
            <
    td>ID</td>
            <
    td>
                <
    input type="text" name="txtid" id="txtid" onkeypress="keydown(event,'txtname');">
            </
    td>
        </
    tr>
        <
    tr>
            <
    td>Name</td>
            <
    td>
                <
    input type="text" name="txtname" id="txtname" onkeypress="keydown(event,'txtaddress');">
            </
    td>
        </
    tr>
        <
    tr>
            <
    td>Address</td>
            <
    td>
                <
    input type="text" name="txtaddress" id="txtaddress">
            </
    td>
        </
    tr>
    </
    table>
    </
    form>
    <
    script>
    document.getElementById('txtid').focus();
    function 
    keydown(e,id){
        if(!
    e)var e=window.event;
        if(
    e.keyCodecode=e.keyCode;
            else if(
    e.whichcode=e.which;
        if(
    code==13){
            
    document.getElementById(id).focus();
        }
    }
    </
    script

  3. #3

    Thread Starter
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416
    thanks...Brown Monk.


    i missed w/ "".

    more power..

Posting Permissions

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



Click Here to Expand Forum to Full Width