howster2011 Posted April 19, 2011 Share Posted April 19, 2011 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); } Quote Link to comment https://forums.phpfreaks.com/topic/234194-php-in-title-attribute-only-first-word-shown/ Share on other sites More sharing options...
Pikachu2000 Posted April 19, 2011 Share Posted April 19, 2011 What shows up in the html source from a View ---> Source? Quote Link to comment https://forums.phpfreaks.com/topic/234194-php-in-title-attribute-only-first-word-shown/#findComment-1203727 Share on other sites More sharing options...
howster2011 Posted April 19, 2011 Author Share Posted April 19, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/234194-php-in-title-attribute-only-first-word-shown/#findComment-1203731 Share on other sites More sharing options...
Pikachu2000 Posted April 19, 2011 Share Posted April 19, 2011 Paste that output in here. Quote Link to comment https://forums.phpfreaks.com/topic/234194-php-in-title-attribute-only-first-word-shown/#findComment-1203732 Share on other sites More sharing options...
dcro2 Posted April 19, 2011 Share Posted April 19, 2011 You didn't wrap it in quotes, so to the browser every word after the first is just another attribute for that tag... title='".$translation."' Also... don't try to use bb code in or [php] tags. Quote Link to comment https://forums.phpfreaks.com/topic/234194-php-in-title-attribute-only-first-word-shown/#findComment-1203733 Share on other sites More sharing options...
howster2011 Posted April 19, 2011 Author Share Posted April 19, 2011 Super! Thanks a million Pikachu2000 and dcro2! Quote Link to comment https://forums.phpfreaks.com/topic/234194-php-in-title-attribute-only-first-word-shown/#findComment-1203742 Share on other sites More sharing options...
howster2011 Posted April 19, 2011 Author Share Posted April 19, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/234194-php-in-title-attribute-only-first-word-shown/#findComment-1203747 Share on other sites More sharing options...
Pikachu2000 Posted April 19, 2011 Share Posted April 19, 2011 <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. Quote Link to comment https://forums.phpfreaks.com/topic/234194-php-in-title-attribute-only-first-word-shown/#findComment-1203752 Share on other sites More sharing options...
howster2011 Posted April 19, 2011 Author Share Posted April 19, 2011 Thanks is this how you would apply the <br> ? $r .="<td class='".$class."'> ".$language."<br><textarea class='textarea Quote Link to comment https://forums.phpfreaks.com/topic/234194-php-in-title-attribute-only-first-word-shown/#findComment-1203753 Share on other sites More sharing options...
Pikachu2000 Posted April 19, 2011 Share Posted April 19, 2011 Yup. Zacly how I'd do it . . . Quote Link to comment https://forums.phpfreaks.com/topic/234194-php-in-title-attribute-only-first-word-shown/#findComment-1203758 Share on other sites More sharing options...
howster2011 Posted April 19, 2011 Author Share Posted April 19, 2011 Works perfect. Many thanks! Quote Link to comment https://forums.phpfreaks.com/topic/234194-php-in-title-attribute-only-first-word-shown/#findComment-1203760 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.