Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 8732 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I would like to able to alternate the row color on my search results page. I've seen several websites that alternate the color of the row where the first row might be white and the second row is light grey to make it easier to read the results. Does anyone know of an easy way to do this? I am using custom web publishing with FM 4.0.3 and right now I am trying to use an If else statement where if the [FMP-CURRENTRECORDNUMBER.eq....] Originally my logic was something like this if the Current Record Number was an even number then make the row color white else make the row color grey. I haven't found an equation that successfully tests for even or odd. Is there some secret command that I don't know about that already does this for you?

Posted

You're on the right track. You've got to nest enough 'if statements' to cover the max records that will be on the page. Here's the table row tag that will handle 4 rows.

<TR

[FMP-IF: CurrentRecordNumber .eq. 1] BGCOLOR="#DDDDDD"

[FMP-Else]

[FMP-IF: CurrentRecordNumber .eq. 3] BGCOLOR="#DDDDDD"

[/FMP-IF]

[/FMP-IF]

>

  • 1 month later...
Posted

I would like to point out that the code provided by dspires is good for both versions 4.0 and 5.0. In 5.0 there is a new [fmp-elseif] tag which allows the same code to be written:

<tr

[fmp-if: currentrecordnumber .eq. 1] bgcolor="#dddddd"

[fmp-elseif: ] currentrecordnumber .eq. 3] bgcolor="#dddddd"

[/fmp-if]

[/fmp-if]

>

Peace

Keith M. Davie

Posted

isnt that going to be a pain in the butt if you have, lets say, 1500 records..

what you need is a simple javascript code and it will work quite well.

code:


<script language="javascript">

var rowcolor = 0

</script>

<table border="0" cellspacing="0" cellpadding="0">

[FMP-record]

<script language="javascript">

if (rowcolor==0)

{

document.write("<tr bgcolor='#FFFFFF'>")

var rowcolor = 1

}

else

{

document.write("<tr bgcolor='#cccccc'>")

var rowcolor = 0

}

</script>

<td>[fmp-field: recordinfo]</td></tr>

[/FMP-record]

</table>


this will make the background color of the rows alternate between white and grey.

i use it to alternate row color on my intranet site.

[This message has been edited by bman (edited March 05, 2001).]

Posted

bman,

Yes using either cdml code is very limiting. Thank you for mentioning the limit.

I was just mentioning the fmp-elseif tag as a cdml way to do it in version 5.0. Not everyone needs JavaScript; but if you are custom publishing FMPro you do need cdml. Not everyone is going to refresh a page with fmp-next and fmp-previous, etc.

As Anatoli says, in combination it can be very powerful - though I would add - in spite of the single-thread limitation of Web Companion, of which we all need to be aware.

Peace

Keith M. Davie

Posted

i wasn't trying to say anything bad about CDML.. its kind of an important part of getting filemaker on the web.

i was just trying to show a more practicle solution to a question that i see get asked many many times on this board.

i was not trying to point out any limitations, all languages (CDML, HTML, javascript, ASP, Perl) have there limitations.

i was simply offering a solutions. whether or not you use it is up to you. but don't dismiss it simply because it is javascript.

Posted

It no problem man, i just see so many people in here dismissing solutions because they involve javascript. The thing is if you really want make a web page, javascript is something you will have to learn sooner or later.

And it is not to hard to learn either. I started learning javascript and CDML at about the same time. Now, i know alot more about javascript than i do CDML.

This topic is 8732 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.