Even easier in JavaScript (so everything can stay in .html). Apply Protaculous to the page, choose prototype-packed in the Library picker, and paste the following into the top Function Body editor:
$$('tr > td').each(function(elm, idx){
elm.innerHTML = elm.innerHTML.gsub(/d+/, (idx + 1));
});
That will substitute the row number for whatever number or group of numbers are found in the first column of the table. You won’t need to increment or change these numbers directly at all, you could use the same placeholder number (1) in each row. If your table has a header row, you may need to remove the + 1 part, because unless you have marked the header row as a header in the Inspector, Freeway will put TDs in that row in place of THs, so your counting would begin at 2. Note also, this will not affect what Google and other non-scripted users see – they would always see the pre-script version with the numeral 1 or whatever you have for a placeholder.
This is a naive approach, by the way, and it applies to every table on the page, so you may need to scope it to a particular table box by adding #item42 or whatever the table’s positioning box is called before the tr in the selector: #item42 tr > td
for example. If you also need to have some rows not have numbers in them for some reason, the script would need to be expanded a little to allow for that:
var counter = 0;
$$('tr > td').each(function(elm, idx){
if(elm.innerHTML.match(/d+/)){
elm.innerHTML = elm.innerHTML.gsub(/d+/, ++counter);
}
});
Walter
On Apr 18, 2012, at 4:14 AM, Mike B wrote:
You could simply add the char before the number when printing the php variable value:
<?php
$theNum++;
echo 'S'.$theNum;
?>
but then why not make it easier! If you set another variable with a letter then you can simply change the letter one time by changing one variable content or setting it to an empty value if a letter is not needed, this way you can update with a letter or remove at a later date and so keep things easy for changes later, so if you now use the following code:
(I have added comments to this which start with //)
<?php
// Set the letter wanted between single (or double) quotes, if no letter then use ''; (two single quotes)
// rather than 'S'; (two single quotes with a letter between them.
$theLetter = 'S';
$theNum = 0;
?>
- Then put a Markup Item in a cell you want numbered and add the following code:
<?php
// Add 1 to the number
$theNum++;
// Print out the value of $theLetter and $theNum variables, would show like: S12
echo $theLetter.$theNum;
?>
HTH
On Apr 18, 2012, at 10:00 AM, Hoffman wrote:
HI Mike,
Thanks for your suggestions.
Will this work if the tables are not just normally numbered like 1,2,3… but also have have an ordered code with letters and numbers?
ex. one table is m1, m2, m3, m4,…M210 another is
S1, S2, S3… S276
Thanks!
Barry
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options