Jump to content

Archived

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

coldkill

Changing value with an onmouseover

Recommended Posts

I'm trying to make a phpBB editor type editor. I've got everything working except a script which is supposed to change the value of a text box depending on what button the user hovered over.
Any help much apreciated
Cold

JS Script:
[code]function tagHelp(name, usage){
    eval("window.document.form."+name+".value = 'Usage: "+usage;+"'");
    
}[/code]

HTML:
[code]                    <tr>
              <td>&nbsp;</td>
              <td class="login"><input type="button" value="Bold" name="bold" onmouseover="javascript:tagHelp(\'use\', \'[b]Bold Text[/b]\');" onclick="javascript:tag(\'b\', \'[b]\', \'Bold*\', \'[/b]\', \'Bold\', \'bold\');" class="submitbutton" />
              <input type="button" value="Paragraph" name="par" onmouseover="javascript:tagHelp(\'use\', \'Text [p] More text\');" onclick="javascript:tag(\'b\', \'[p]\', \'Paragraph\', \'[p]\', \'Paragraph\', \'par\');" class="submitbutton" />
              <input type="button" value="URL" name="url" onmouseover="javascript:tagHelp(\'use\', \'[url=http://www.url.com]URL Text[/url] OR [url]http://www.url.com[/url]\');" onclick="javascript:tag(\'b\', \'[url]\', \'URL*\', \'[/url]\', \'URL\', \'url\');" class="submitbutton" />
              <input type="button" value="Center" name="cen" onmouseover="javascript:tagHelp(\'use\', \'[center]Centered Text[/center]\');" onclick="javascript:tag(\'b\', \'[center]\', \'Center*\', \'[/center]\', \'Center\', \'cen\');" class="submitbutton"/>
              <input type="button" value="Italic" name="it" onmouseover="javascript:tagHelp(\'use\', \'[i]Italic Text[/i]\');" onclick="javascript:tag(\'b\', \'[i]\', \'Italic*\', \'[/i]\', \'Italic\', \'it\');" class="submitbutton" />
              <input type="button" value="Underline" name="und" onmouseover="javascript:tagHelp(\'use\', \'[u]Underlined Text[/u]\');" onclick="javascript:tag(\'b\', \'[u]\', \'Underline*\', \'[/u]\', \'Underline\', \'und\');" class="submitbutton" />
              <input type="button" value="Quote" name="qut" onmouseover="javascript:tagHelp(\'use\', \'[quote=Name]Quoted Text[/quote] OR [quote]Quoted Text[/quote]\');" onclick="javascript:tag(\'b\', \'[quote]\', \'Quote*\', \'[/quote]\', \'Quote\', \'qut\');" class="submitbutton" />
              <input type="button" value="Image" name="img" onmouseover="javascript:tagHelp(\'use\', \'[image]http://www.url.com/image.jpg[/image]\');" onclick="javascript:tag(\'b\', \'[image]\', \'Image*\', \'[/image]\', \'Image\', \'img\');" class="submitbutton" />
              </td>    
            </tr>[/code]

The HTML is in a PHP echo.

Share this post


Link to post
Share on other sites
if you're wanting to perform it when on hover
you should use onMouseOver instead of MouseOut

and also on your script
[code]function tagHelp(name, usage){
    eval("window.document.form."+name+".value = Usage: usage;");
    
}[/code]

usage should be outside the quotes the same as name
like so
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]function tagHelp(name, usage){
eval("window.document.form."+name+".value = Usage:[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--][b]"+usage+"[/b][!--colorc--][/span][!--/colorc--];");

}[/quote]
and if I'm not mistaken you should have to put single quotes around the new value
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]function tagHelp(name, usage){
eval("window.document.form."+name+".value = [!--coloro:#3366FF--][span style=\"color:#3366FF\"][!--/coloro--]'Usage:"+usage+"'[!--colorc--][/span][!--/colorc--];");

}[/quote]

Share this post


Link to post
Share on other sites
Yes i changed it to onmouseout instead of over to see if it would make a difference. Just forgot to update it :S.

Changed it to what you suggested and it still didn't work.

Updated the code above.

::EDIT::
NVM typo.

Thanks v. much.

[b]::CLOSED::[/b]

Share this post


Link to post
Share on other sites

×

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.