...

View Full Version : returnvalues as parameters for HTML-tags



TsukiShimizu
07-11-2011, 07:01 PM
Hello.

I'm working on a progressbar for my blog, and I've looking for a method to easily controll the text it shows, since it's always one of 8 states.

For this i wanted to create a javascript and a switch which would give the right percentage of filling for the progressbar. Unfortunatly it doesn't fill the progressbar as wanted.


<script type="text/javascript">
var t = 6;

function percent()
{
switch (t)
{
case 1:
return 12.5;
break;
case 2:
return 25;
break;
case 3:
return 37.5;
break;
case 4:
return 50;
break;
case 5:
return 62.5;
break;
case 6:
return 75;
break;
case 7:
return 87.5;
break;
case 8:
return 100;
break;
case 0:
return 0;
break;
default:
return 0;
}
}
</script>

<div class="”goal”" style="”width:195px;height:15px;background:#0d0d1c;border:solid" 1px="">
<div class="”progress”" style="height:15px;background:#1e90ff;color:white;width:javascript:percent()%"><b>0</b>
</div></div>


Could someone show me where I am going wrong with this please?
And if it matters: My blog is a *.blogspot.com
Thanks

rnd me
07-11-2011, 07:13 PM
<body>


<progress class='progress'></progress>


<script>
function percent(t){
return document.getElementsByClassName("progress")[0].value=(
{ 1: 12.5, 2:25, 3:37.5, 4:50, 5:62.5, 6:75, 7:87.5, 8:100}[t]||0)/100;
}
</script>


Set Progress:
<input value='1' type='button' onclick="percent(this.value)" />
<input value='3' type='button' onclick="percent(this.value)" />
<input value='4' type='button' onclick="percent(this.value)" />
<input value='6' type='button' onclick="percent(this.value)" />
<input value='8' type='button' onclick="percent(this.value)" />


</body>

tested ff6, ch13

TsukiShimizu
07-11-2011, 07:21 PM
This isn't what I wanted, but I figured out, I can't use the returnvalue of a javascript-function as an input for an HTML-Tag.

Can be closed.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum