Jump to content

php in title attribute - Only first word shown


howster2011

Recommended Posts

Hi Guys,

New to php! I have a title attribute applied to a textarea but in the below code the title attribute just displays the first word of the associated sentence, if $translation is "The cat is on the mat" the title attribute on mouseover of the textarea only shows "The". Weird eh? Any ideas what the fix would be. Same in IE, Chrome and FF. How could I tweak this ".$translation." (highlighted in red in code below off to the right) in the context of the below code? It aint my code by the way :) By the way ".$translation." highlighted in green does show the full sentence eg "The cat is on the mat"

I need the title attribute as a tooltip on a big matrix of textareas.

Thanks

 

		foreach ($translation_matrix[$this->ext->settings['base_language']] as $phrase_key => $translation)
	{
		$class = ($i % 2) ? "tableCellOne" : "tableCellTwo";
		$r .= "<tr>";
		$r .= "<td class='".$class." phrase-key'>".$phrase_key."</td>";
		$r .= "<td class='".$class."'>[color=green]".$translation."[/color]</td>";
foreach ($matched_langs as $lang_key => $language)
		{

			$r .="<td class='".$class."'> ".$language."<textarea class='textarea' name='translations[".$lang_key."][".$phrase_key."]' title=[color=red]".$translation."[/color]>".((isset($translation_matrix[$lang_key][$phrase_key]) === TRUE) ? $translation_matrix[$lang_key][$phrase_key] : "")."</textarea></td>";
		}
		$r .= "</tr>\n";
		$i++;
	}
	$r .= "</tbody></table><input type='submit' value='".$LANG->line("submit")."' />";

	$r .= "</form>";

	$this->_render_layout('index', $r);
}

In view source $translation in the table cell shows the full sentence yet in the title attribute it shows just the first word.

If the sentence is:

"A house is big" the title attribute will only render "A" on the screen and in the source- Space between words breaks it but if &translation is called in a table cell you see the full sentence.

One last question please

 

$r .="<td class='".$class."'> ".$language."<textarea class='textarea

 

how do i apply a line break \n (i think) so that the output from $language is above the textbox

 

I need e.g the word "English" on top of the textbox and not on the left of it in the table cell (Only an issue in IE7)

 

correct:

English

[textbox]

 

incorrect:

English[textbox]

 

...just unsure of the \n syntax.

<br /> or <br> didn't work for me.

Thanks

<br> *should* work for that, but you may be better off setting it as a caption, and using CSS to position it.

 

You really don't need all that string concatenation, BTW. All it does is add confusion and lead to typos, IMO.

 

$r .="<td class=\"$class\">$language<textarea class=\"textarea\">, etc.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.