Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2009
    Posts
    88
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Function works too late

    Hello again

    I'm trying to execute a function directly when I hit the submit button, now the function verminderen() executes onchange, I know it must be something like onchange, but that does't seems to work.

    Head part
    Code:
    <script type = "text/javascript">
    function CopyIt(){
    var aform = document.form.u.value;
    document.newurlform.newurl1.value = aform;
    }
    
    function verminderen() {
    var a = document.getElementById("newurl1").value;  // Haal de text in txt1 op
    var len1 = a.length; // zet txt1 om in lengte
    
    var b = document.getElementById("newurl2").value;  // Haal de text in txt2 op
    var len2 = b.length;
    var c = len1 - len2;
    var d = c / len1;
    var e = Math.round(d * 100);
    var e1 = "URL is met ";
    var f = e; //nu moeten we het omdraaien
    var f1 = " % gereduceerd!";
    var f3 = " %";
    var f2 = e1 + f + f1;
    document.getElementById("uitkomst1").innerHTML = f2;
    document.getElementById("uitkomst2").innerHTML = e + f3;
    // document.newurlform.newurl.value = f2;
    }
    </script>
    Body part:
    Code:
        <form {$form.attributes} class="s6l_short_url_form" onchange="CopyIt();>
        {$form.hidden}        
        
        <div>
          {if $form.u.error} <span class="s6l_error_message">{$form.u.error}</span> {else} {$form.u.label} {/if}
          {$form.u.html}&nbsp;&nbsp;
          {$form.submit.html}
          &nbsp;<a href="?a=y">{$txt_advanced}</a>
        </div>
        {if $show_advanced_settings}
          <div style="margin-top:10px;">
             {if $form.u_id.error} <span class="s6l_error_message">{$form.u_id.error}</span><br />{else}{/if}
             {$form.u_id.label}&nbsp;
             {$form.u_id.html}&nbsp;&nbsp;
          </div>
        {/if}
        </form>
        
        
        {if $show_short_url}
        <div class="s6l_short_url_result">
          <p>{$txt_short_url_text} {$output_message}</p>
    
          <p><a href="{$output_url}">{$output_url}</a></p>
    <form name="newurlform" onclick="CopyIt(); verminderen();">
    
    <input type="hidden" id="newurl1" value=""/>
    
          <div class="s6l_short_url_form_text_area"><textarea name="newurl" id="newurl2" cols="50" rows="4" wrap="physical" onkeyup="limiter()" {literal}onfocus="if (typeof(document.layers) == 'undefined' || typeof(textarea_selected) == 'undefined') {textarea_selected = 1; document.newurlform.elements['newurl'].select();}" {="{" literal}="literal}">{/literal}{$output_url}</textarea></div>
    </div>
    
       <div class="" id="uitkomst1"></div>
    <div class="" id="uitkomst2"></div>             
    
    
    <div class="s6l_short_url_form1" id="myDiv"></div>
      
    <div class="s6l_short_url_form2"><a href="javascript:getready ();"><img src="../template/default/image/twitten.png" alt="Klik hier om de TwitURL te Twitten" width="171" height="44" border="0" align="right"></a></div>
    
    <div class="s6l_short_url_form3"><a href="javascript:selectAll ();"><img src="../template/default/image/select_all.png" alt="Klik hier om alles te selecteren" width="136" height="25" border="0" align="right"></a></div>
    
    
    </div>
    </form>

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,554
    Thanks
    80
    Thanked 4,620 Times in 4,583 Posts
    onsubmit, not onchange and not onclick



    What server side language is that??? It looks like PHP, but it doesn't use PHP tags.


  •  

    Posting Permissions

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