...

View Full Version : Function works too late



boemboem
06-15-2009, 10:50 PM
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

<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:

<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>

Old Pedant
06-15-2009, 11:20 PM
onsubmit, not onchange and not onclick



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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum