tinymce: clear field

Categories: javascript, ajax, tinymce

Tags: clear, tinymce, xajax

the normal way to clear <textarea> field:

Code:

document.formname.textareaid.value = '';

for <textarea> converted into tinymce editor, the above javascript call does not work. you need to call tinyMCE.setContent()

Code:

tinyMCE.getInstanceById('textareaid').setContent('');

to call from xajax function:

Code:

$xajax->script("tinyMCE.getInstanceById('textareaid').setContent('');");

javascript: tooltips

Categories: javascript, bookmark, free

Tags: dhtml, free, javascript, overlib, popup, tooltip, wz_tooltip

it’s bubble help on your website, like bubble helps on windows applications. hover your mouse over a link to show a small non-invasive popup box of information.

overLIB

i’ve been using this library on a few of my projects for a few years. (first read about it from scripty goddess.)

useful links: download (latest version is V4.21 released in 2005), basic instructions, command references.

note about IE: when displaying tooltips on html forms, the tip will hide behind drop down boxes. this happens on IE. solution? include ‘overlib_hideform.js’ on the html page.

wz tooltip

i found out about this when i was looking for browser / web drag and drop libraries.

the usage is like overLIB. there’s one additional feature that overLIB doesn’t have (unless it was overlooked). this library has the capability to convert html element into tooltip.


wow: item tool tips

Categories: javascript, b2evo

Tags: b2, itemstat, javascript, wow, wowhead

i’ve been wanting to add item tool tips to my wow blog. you know, the cool popup text displayed when you move your mouse over an item link. like how it looks in-game.

the first came to mind was itemstats, which i’ve used to setup websites for my previous guilds. however it does not support b2.

since there will be no further developments on itemstats, i thought about doing a plugin. but i need to learn how to write a plugin and it seems complicated. the project was put aside.

then i discovered wowhead tooltips (via reading posts from blog azeroth). it’s even simpler to implement, but requires additional steps to use.

i did some minor modifications to instruction.

add this anywhere on the page:

Code:

<script type="text/javascript" src="http://www.wowhead.com/widgets/power.js"></script>

note: i put this in the skin’s index.main.php. this is perhaps not the best way. if you change your skin, it will not work. but if you’re sure you will never change to another skin, then it shouldn’t be a problem.

where you want to place the link:

Code:

<a class="qx" href="http://www.wowhead.com/?item=number">name</a>

go to wowhead to look up the item / spell you want. copy and paste name and url.

for class qx, replace x with numbers 0 to 5 to indicate color of the link / item:

  • 0 - gray - poor
  • 1 - white - common
  • 2 - green- uncommon
  • 3 - blue - rare
  • 4 - purple - epic
  • 5 - orange - legendary

no need to define these colors in your own css. it’s all done for you.

if background of your site is white, you will have problem displaying the white item.


drag and drop

Categories: javascript, html, bookmark, free

Tags: drag and drop, free, javascript

i was looking for drag and drop functionality / components for websites and found this javascript based library.

it seems easy for simple implementation. just download the file and follow 4-step instructions.

however fore more advanced / complicated implementation, knowledge of javascript is required. (my weakest link…) it’d be nice if i can find a php-based code. probably will have to implement this with xajax to avoid javascripts…


xajax and checkbox

Categories: javascript, php, ajax

Tags: checkbox, xajax

in one of the forms i work on, i need to set other form fields based on the value of a checkbox. the value this.checked was passwd a parameter to xajax function.

Code:

<input type="checkbox" name="checkbox1" id="checkbox1" value="Y" onClick="xajax_function(this.checked);" />

in xajax function, the value of the parameter is either true or empty value.

PHP:

function xajax_function($data) {
    $obj = new xajaxResponse();
    $obj->assign("field1""value"$data "true value" "false value");
    return $obj;
}

the problem is, the value in field1 always display “true value” whether the box is checked or not!

it turns out that the true passed is a string! not boolean! you need to compare $data and “true” (with quotes).

replace line 3 of above php code:

PHP:

$obj->assign("field1""value", ($data == "true") ? "true value" "false value");

now it works as intended.

alternatively check with isset($data) to see if checkbox is checked.

to check the opposite value, ie checkbox is not checked, use !isset($data).

note: do not use / pass this.value as parameter. the value will always be the value assigned to checkbox, in this case, always “Y".


1 2 3 »

Affliates

Spreadfirefox Affiliate Button