Link to home
Start Free TrialLog in
Avatar of macuser777
macuser777Flag for United Kingdom of Great Britain and Northern Ireland

asked on

make dynamically generated button text bold

Hi how can I make this part of the code bold. I tried strong. tags but they just printed into the button.



<?=$displayOnlyInCat?>


from this php page code

<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="6" height="42" background="http://www.domain.com/images/cats/open_lbg.gif"></td>

    <td background="http://www.domain.com/images/cats/openbg.gif">

        <input name="search" type="textfield" style="width:130px;" value="<?php echo $_COOKIE['term'] ; ?>">

        <input type="submit" name="submit" value="Search in <?=$displayOnlyInCat?> Category" >

        <input type="hidden" name="cat" value="<?=$onlyInCat?>"><input type="hidden" name="all" value="no"></td>

    <td width="6" height="42" background="http://www.domain.com/images/cats/open_rbg.gif"></td>
  </tr>
</table>

Avatar of rockmansattic
rockmansattic

css.
<input type="submit" name="submit" value="Search in <?=$displayOnlyInCat?> Category" style="font-weight:bold; ";>
 

Rockman
Avatar of macuser777

ASKER

Hi

But I only want

<?=$displayOnlyInCat?>

part in bold
and this has failed ?
<input type="submit" name="submit" value="Search in<b><?=$displayOnlyInCat?></b> Category">
I don't think you can do that using only an <input> tag.

Try using a blank value in the <input> tag. Then setup a <div> tag on top of the botton with the text formatted in the way you need it. You would need javascript to submit the form after the onclick event on top of the <div> tag.
Sound ugly, but this is the first thing I could think of.
here are a couple of different ways from here in EE
<script>
function ChangeFont(size)
{document.getElementById("text2").style.fontFamily="Arial";
document.getElementById("text2").style.fontWeight="bold";
document.getElementById("text2").style.fontSize=size;}
</script>
<div align="center">
<p><br><span style="font-family: Times New Roman; font-size: 16px;" id="text2">Page Header</span></p>
</div>
<input type="button" value="Change It" onClick="ChangeFont('11px');">

or

<span id="text2" style="font-family: Times New Roman; font-size: 16px;">Page Header</span>
<br>
<input type="button" value="Bold" onClick="document.getElementById('text2').style.fontWeight = 'bold'">
<input type="button" value="Italic" onClick="document.getElementById('text2').style.fontStyle = 'italic'">

good luck.
>>>>><input type="submit" name="submit" value="Search in<b><?=$displayOnlyInCat?></b> Category">

yeah - tried that , and <strong> tags as well. Just prints into input button like text.

>>>good luck.

you're not kidding! :)

Javascript ??? - hmmmm....i'll have to save up some more points I think.....:)

and...may be being dense...but can't see how that would just bold <?=$displayOnlyInCat?> and not all text in button......

hmmmm...maybe if I make static images of static text and put them next to bolded button with dynamic text.....hmmm dunno...i'll let you know

It's a small thing ... but it would make navigation clearer
hmmmm
how about try something like this.
<input type="submit" name="submit" value="Search in'<b>'<?=$displayOnlyInCat?>'</b>' Category">

I am not really sure about the placement of the single ticks. but I am thinking it might work i know in jsp you can use single ticks to add code to tags. just a thought might not work but if it did it would be a great simple solution.
Unfortunately not. That printed into button as text as well.
<button type="submit" name="submit">Search in <b><?$displayOnlyInCat?></b></button>
(May not work in all old browsers)
Tried it in Mozilla and safari. It leaves out the dynamic part of button text altogether. Button just says 'search in'

ASKER CERTIFIED SOLUTION
Avatar of StormyWaters
StormyWaters
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It would be easier to create a gif, that looks like input button, then have the text dynamically overlay the image, and have the image dynamically expand to fit the text.

But I suggest considering just how important just that text is to be bold?

Good Luck

Rockman
Ah I scrolled through all of that and pow, stormywaters has the answer !  And as he pointed out, yes, not all older browsers support <button>.
>>>><button type="submit" name="submit">Search in <b><?=$displayOnlyInCat?></b></button>

:))))))))))

StormyWaters, it works like a charm in mozilla based, IE for Mac, Opera and Netscape on my mac.


In safari it bolds in the right place but changes the button style from the Mac default Aqua type to something more like a windows IE button. That's was ok, but it also in safari  it then put the button on a new line. Dealt with that by using

style="display:inline;"