www.webdeveloper.com
Results 1 to 3 of 3

Thread: Help me plz it 's error (passing value to function when click link)

  1. #1
    Join Date
    Nov 2002
    Posts
    2

    Unhappy Help me plz it 's error (passing value to function when click link)

    plz help me.
    I found the error when i run it. For my propose, i want to sent values to function when click links and show a value that has sent into textbox. I had made two links for testing passing value to function but it didn't work it don't sent value to "loadToTextBox" function.
    Please help me for solving this problem ~-_-~.

    Thank in advance
    From Aranyuth
    //////////////////it don't work, i want to do like this/////////////////////
    <html>
    <script language="javascript">
    <!--
    function loadToTextBox(code, bg_or_font) {
    if(bg_or_font == "bg") {
    document.submitColor.bg_code.value = code;
    }else{
    document.submitColor.font_code.value = code;
    }
    }
    //-->
    </script>

    //
    <!--<body OnLoad=loadToTextBox('ff')>-->
    <body>
    <form method="post" action="" name="submitColor">
    <input type="text" name="bg_code">
    <input type="text" name="font_code">
    </form>

    //first links for testing
    <a href="javascript:loadToTexBox('ff', 'bg')">000000</a>
    //second links for testing
    <a href="choose_bg_font_color.html" OnClick=loadToTexBox('ff', 'bg');">000001</a>

    </body>
    </html>
    //////////////////////////////////////////////////

    //////////////////it it like this, it work why?? ///////////
    // i'm confuse
    <html>
    <script language="javascript">
    <!--
    function loadToTextBox(code) {
    document.submitColor.bg_code.value = code;
    }
    //-->
    </script>

    //
    <body OnLoad=loadToTextBox('ff')>
    <form method="post" action="" name="submitColor">
    <input type="text" name="bg_code">
    <input type="text" name="font_code">
    </form>

    //first links for testing
    <a href="javascript:loadToTexBox('ff', 'bg')">000000</a>
    //second links for testing
    <a href="choose_bg_font_color.html" OnClick=loadToTexBox('ff', 'bg');">000001</a>

    </body>
    </html>
    ///////////////////////////////////////

  2. #2
    Join Date
    Nov 2002
    Posts
    4,473

    Re: Help me plz it 's error (passing value to function when click link)

    Originally posted by aranyuth
    <a href="javascript:loadToTexBox('ff', 'bg')">000000</a>
    Shouldn't this be
    <a href="javascript:loadToTextBox('ff', 'bg')">

    <a href="choose_bg_font_color.html" OnClick=loadToTexBox('ff', 'bg');">000001</a>
    and this should be
    <a href="choose_bg_font_color.html" OnClick="loadToTextBox('ff', 'bg');">

    Also, this link will change your page and clobber all your variables, so the onClick won't do you any good even if you fix the syntax errors.

  3. #3
    Join Date
    Nov 2002
    Posts
    2

    Thank you so much

    Thank you so much

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles