PostIT

while scratching my head…

Get Parent URL With Javascript December 6, 2009

Filed under: Javascript — Remo @ 7:40 am

I frequently have to create child window and the child windows sometimes need its parent URL, in javascript just create a variable to store the url. In this example I copy the content of parentURL variable to a hidden form element named sourceURL

<script type="text/javascript">
function frmSubmit(){
    parentURL = opener.location.href;
    document.getElementById('sourceURL').value = opener.location.href;
    document.forms['myform'].submit();
}
</script>
<form name="myform" id="myform" method="post" action="target.php">
<input type="hidden" name="sourceURL" id="sourceURL" />
<input type="button" value=" submit " onclick="frmSubmit()" />
</form>
 

Enable File Upload on FCKEditor (PHP) October 3, 2009

Filed under: Javascript, PHP — Remo @ 7:13 am
Tags: , ,
  • Edit
    fckeditor/editor/filemanager/connectors/php/config.php
  • Modify $Config['UserFilesPath']
    Put your application folder here
    Eg:
    $Config['UserFilesPath'] = ‘/myapp/’ ;
  • Modify $Config['UserFilesAbsolutePath']
    Put your application full path here. Windows users should use double backslash here
    Eg:
    $Config['UserFilesAbsolutePath'] = ‘/var/www/myapp/’ ;

    or

    $Config['UserFilesAbsolutePath'] = ‘C:\xampp\htdocs\myapp\’ ;

  • After that, you can customize other variable, like these

$Config['FileTypesPath']['File']        = $Config['UserFilesPath'] . ‘images/’ ;

$Config['FileTypesAbsolutePath']['File']= ($Config['UserFilesAbsolutePath'] == ”) ? ” : $Config['UserFilesAbsolutePath'].’images/’ ;

$Config['FileTypesPath']['Image']        = $Config['UserFilesPath'] . ‘images/’ ;

$Config['FileTypesAbsolutePath']['Image']= ($Config['UserFilesAbsolutePath'] == ”) ? ” : $Config['UserFilesAbsolutePath'].’images/’ ;

$Config['FileTypesPath']['Flash']        = $Config['UserFilesPath'] . ‘images/’ ;

$Config['FileTypesAbsolutePath']['Flash']= ($Config['UserFilesAbsolutePath'] == ”) ? ” : $Config['UserFilesAbsolutePath'].’images/’ ;

$Config['FileTypesPath']['Media']        = $Config['UserFilesPath'] . ‘images/’;

$Config['FileTypesAbsolutePath']['Media']= ($Config['UserFilesAbsolutePath'] == ”) ? ” : $Config['UserFilesAbsolutePath'].’images/’ ;

You can put different filetype on different upload location. In this example I put all filetype on images folder

 

Dynamic form elements and Internet Explorer 6 June 30, 2009

Filed under: Internet Explorer, Javascript, Web Development — Remo @ 7:12 am

A few brief entries from the ‘tiny yet annoying bugs that take far too much time to fix’ file…

I’m creating forms dynamically using JavaScript. This has led to a number of problems with IE6:

Dynamic checkboxes/radio buttons and the ‘checked’ attribute

When creating a field, I wanted to be able to apply a ‘default’ value — for example, a checkbox element might be ticked by default. This was all going smoothly until (guess what?) I tested it on IE6: the checked attribute was set, and returned ‘true’ when tested, but the box did not appear to be checked when it appeared in the form.

The answer, as I discovered thanks to this forum post, was to use the ‘defaultChecked’ attribute instead (I set both, just in case). It seems to work across browsers, which is nice. Oh, and this applies to radio buttons as well as checkboxes.

Creating radio buttons

While we’re on the subject of radio buttons, I also found that IE6 doesn’t like radio buttons created using document.createElement() (i.e. as a DOM object). It’ll render them OK, but they’re unclickable. The answer is to create them by injecting HTML into an element with [element].innerHTML:

var obj = document.createElement( ’span’ );
obj.innerHTML = ‘<input type=”radio” name=”somefield” value=1>1′;

…and so forth. Ugly.

Assigning values to multiple select elements

This was a really fiddly one, and seems to happen under only very particular circumstances. Anyway…

If you create a select element and set the ‘multiple’ attribute, IE6 can sometimes have trouble assigning values to it if you do it immediately after it’s created. Note the word ’sometimes’: I haven’t been able to create a simple enough test case to isolate the exact circumstances that are required. And it’s only a problem if you’re setting more than one value.

Anyway, the (horrible) fix is to delay setting the values using setTimeout(). The delay doesn’t matter (1 millisecond will do), but it does work.

I hope these notes help some other unfortunate soul out there avoid wasting the number of hours and brain cells that I just have!

source:

http://the-stickman.com/web-development/javascript/dynamic-form-elements-and-internet-explorer-6/

 

Javascript, jQuery, Tutorials… April 17, 2009

Filed under: Javascript, jQuery — Remo @ 2:08 am

JQUERY PLUGINS

JAVASCRIPT

TUTORIALS

 

PHP and FCKEditor April 2, 2009

Filed under: Javascript, PHP — Remo @ 5:21 am

1. Download and extract FCKEditor

2. Put this before create instance

include_once(“fckeditor/fckeditor.php”);

3. Put this to load the editor

$oFCKeditor = new FCKeditor(‘p_content’) ;
$oFCKeditor->BasePath = ‘fckeditor/’ ;
$oFCKeditor->Width    = ‘100%’ ;
$oFCKeditor->Height   = ‘600′ ;
$oFCKeditor->Value    = “$pContent” ;
$oFCKeditor->Create() ;

p_content is the (form) element name

make sure the BasePath is correct

 

jQuery Simple Drop Down Menu March 9, 2009

Filed under: Javascript, jQuery — Remo @ 6:54 am
Tags: , ,

I usually use Ger Versluis’ HV Menu which can be downloaded here

I found a bit simpler alternative here, it is based on jQuery.

I said a bit simpler because we only define the menu structure in a UL block.

If you like simplicity, have a visit to the demo page

 

Javascript – Ubah Gambar August 5, 2008

Filed under: Javascript — Remo @ 6:30 am
Tags:

document[img_name].src = img_src;

 

Javascript – Bikin Popup Konfirmasi July 30, 2008

Filed under: Javascript — Remo @ 4:48 am
Tags:

cukup pake kaya gini:

if (confirm(“Are you sure you want to DELETE ALL DATA?”)){

location.href = “http://localhost/delete_all.php”;

}