Jump to content

Recommended Posts

Posted

Hallo,

on a page i got 9 fields for Tabs. How can i access the data like in the following example?
The way i am trying it, guess what , doesn't work. Any suggestions?

<?php
   for($i = 1; $i <= 9; $i++) {
     echo "<input id='tab{$i}' type='radio' name='tabs' class='inputtab'";
     if($i == 1) echo " checked='checked'";
     echo ">\n";
     echo "<label for='tab{$i}' class='labeltab'>$page->Tab.$i</label>\n";
   }
?>

Same on the TabContent

<?php
   for($i = 1; $i <= 9; $i++) {
     echo "<div id='content{$i}'>";
     echo "<p>$page->TabContent.$i</p></div>";
   }
?>

 

 

Posted

So the fields are named Tab1...Tab9 resp. TabContent1...TabContent9? In that case, two possibilities immediately come to mind, but both require you to assemble the name outside of the quotes (there might be a way inside the strings, but I can't think of one right now).

<?php
//...
	$tabname = "Tab" . $i;
	echo "<label for='tab{$i}' class='labeltab'>{$page->$tabname}</label>\n";

Or, in one go:

<?php
//...
	echo "<label for='tab{$i}' class='labeltab'>" . $page->get("Tab" . $i) . "</label>\n";

 

  • Like 3

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...