Changing some js-code (BBcode-functions)

Discussion in 'JavaScript' started by PoPSiCLe, Jun 10, 2009.

  1. #1
    I have the following javascript code:
    
    else if(tag == 'img')
    	{
    		var path = prompt('Enter link', 'http://');
    		var classAlign = prompt('Chose alignment: left, right or center');
    		var altText = prompt('Description');
    		if(!path || !classAlign || !altText)
    		{
    			return;
    		}
    		if (document.selection) 
    		{
    			field.focus();
    			var selected = document.selection.createRange().text;
    			var ins = '[' + tag + '='+path + ' ' + classAlign + ' ' + altText + ']' + altText + '[/' + tag+']';
    			var selected2 = document.selection.createRange();
    			var sel = document.selection.createRange();
    			sel.text = '[' + tag + '='+path + ' ' + classAlign + ' ' + altText + ']' + altText + '[/' + tag+']';
    			selected2.moveStart ('character', -field.value.length);
    			sel.moveStart('character', selected2.text.length + ins.length - selected.length);
    		}
    
    Code (markup):
    What I would like to do is the following:
    I would like to make the "chose alignment" a radio-button-choice, instead of prompt where the user would have to write in the value.
    I would also like to add a possible choice between "enter url" or "chose file for upload", if possible

    Would it be possible to amend the script for my needs?

    This is of course not the whole script, just the part pertaining to the picture upload.

    Any help would be greatly appreciated.
     
    PoPSiCLe, Jun 10, 2009 IP