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
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    I'm bumping this - anyone have any tips for how to make this work as I want (read first post)?

    Any help would be appreciated!
     
    PoPSiCLe, Jun 15, 2009 IP
  3. Unni krishnan

    Unni krishnan Peon

    Messages:
    237
    Likes Received:
    9
    Best Answers:
    2
    Trophy Points:
    0
    #3
    Posting a piece of code.
    You can extract your needed things from this.



    Hope this helps.
     
    Unni krishnan, Jun 16, 2009 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    Well, it does, sort of. It's just that I want the radio-buttons for left/right/center to be available in the pop-up box (ie, I don't really want to do a window.open). The current solution is just using .prompt to open an input text-field, and the user can then write either left,right or center - what I want is for the user to just click on either left, right or center and the value will be passed to the rest of the javascript. Prompt won't do this of course, so what I'm looking for is another function that will let me put html-code in what is more or less an alert-box - but I don't know if this is possible using "plain" javascript.
     
    PoPSiCLe, Jun 21, 2009 IP