Improvement suggestion for scriptcase

We seem to have all kinds of sc_field_… functions and with { … } we can mention fields.
I would like to be able to loop through all my fields on the screen and I dont really see a way to do that.
I know I have sc_getfield but that is insufficient. Say I have 13 similar fields in my database:
JOBDT1, JOBDT2, …
I would like to be able to make a loop like:
for ($i=1;i<=13;i++){
$field=getactualfield(‘JOBDT’.(string)$i);
$field.value=$i * 365;
}

Kind of like a real programming language (hint delphi) where you can loop through all the fields, buttons and what else.
This would make things a lot easier for pages with many fields. And one could make a loop for example that disables/hides all fields that are not filled or whatever.

Well, until there is a macro for it you can use javascript.


for(var i=0; i<jposArray.length; i++)
{
	pos = parseInt(jposArray.item(i).firstChild.data);
	scores.push(parseFloat(jscoreArray.item(i).firstChild.data));
	document.getElementById('id_sc_field_s'+ pos).value = jscoreArray.item(i).firstChild.data.replace('.',','); 
	document.getElementById('id_sc_field_p'+ pos).value = j5pArray.item(i).firstChild.data;
	if(parseInt(jstatArray.item(i).firstChild.data) == '3')
	{
		checkboxes[pos-1].checked = true;
		document.F1.erf_status.value = 3;
	}
	if(j5pArray.item(i).firstChild.data != penalty)
	{
		document.F1.erf_status.value = 3;
	}
}

Or if you want to stay within php, call your fields by reference.


$scores = array(&{s1}, &{s2}, &{s3}, &{s4}, &{s5});
for($i = 1; $i <= count($scores); $i++) //you could use foreach as well
{
    $scores[$i] /= 10;
}

jsb

Interesting! That the javascript way was possible I knew. I wanted to do it in scriptcase without much coding sepcially since we could use such loops regularly.
That last one I didnt think of, nice… I like it.

[QUOTE=rr;26993]Interesting! That the javascript way was possible I knew. I wanted to do it in scriptcase without much coding sepcially since we could use such loops regularly.
That last one I didnt think of, nice… I like it.[/QUOTE]
I tend to join. This is the really interesting idea to implement. It looks helpful although being unusual.

Hello,

I will discuss your suggeston with our team.

regards,
Bernhard Bernsmann