Javascript alertbox help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Javascript alertbox help

    I need help about javascript alertbox
    when giving link in textarea a javascript alert will open where the link should put and after putting the link the link will automatically putted in the textarea. can anyone help plz?

    #2
    PHP Code:
    <html>
     <
    head>
     <
    script type="text/javascript">
    //url prompt to textarea, by something else on coding-talk.com forums :P
     
    function addurl()
     {
         var 
    url=prompt('enter a url','http://');
         if (
    url!=null && url!="" && url!="http://")
        {
            var 
    details document.getElementById('str').value;
            
    document.getElementById('str').value details+'[url='+url+']'+url+'[/url]';
        }
     }
     </
    script>
     </
    head>
     <
    body>

     <
    input type="button" onclick="addurl()" value="Add Url" />
     <
    textarea id="str" cols="50" rows="11"></textarea>
     </
    body>
     </
    html
    Last edited by something else; 03.03.12, 21:28.

    Comment


      #3
      how to use this code! this is much smarter than normal alert box but i can't make it work. please bro check this to work with.
      Attached Files

      Comment


        #4
        try:
        PHP Code:
        // Apprise 1.5 by Daniel Raftery
        // http://thrivingkings.com/apprise
        //
        // Button text added by Adam Bezulski
        //
        //url prompt to textarea, by something else on coding-talk.com forums :P 
         
        function addurl() 
         { 
             var 
        url=prompt('enter a url','http://'); 
             if (
        url!=null && url!="" && url!="http://"
            { 
                var 
        details document.getElementById('str').value
                
        document.getElementById('str').value details+'[url='+url+']'+url+'[/url]'
            } 
         }

        function 
        apprise(stringargscallback)
            {
            var 
        default_args =
                {
                
        'confirm'        :    false,         // Ok and Cancel buttons
                
        'verify'        :    false,        // Yes and No buttons
                
        'input'            :    false,         // Text input (can be true or string for default text)
                
        'animate'        :    false,        // Groovy animation (can true or number, default is 400)
                
        'textOk'        :    'Ok',        // Ok button default text
                
        'textCancel'    :    'Cancel',    // Cancel button default text
                
        'textYes'        :    'Yes',        // Yes button default text
                
        'textNo'        :    'No'        // No button default text
                
        }
            
            if(
        args
                {
                for(var 
        index in default_args
                    { if(
        typeof args[index] == "undefined"args[index] = default_args[index]; } 
                }
            
            var 
        aHeight = $(document).height();
            var 
        aWidth = $(document).width();
            $(
        'body').append('<div class="appriseOverlay" id="aOverlay"></div>');
            $(
        '.appriseOverlay').css('height'aHeight).css('width'aWidth).fadeIn(100);
            $(
        'body').append('<div class="appriseOuter"></div>');
            $(
        '.appriseOuter').append('<div class="appriseInner"></div>');
            $(
        '.appriseInner').append(string);
            $(
        '.appriseOuter').css("left", ( $(window).width() - $('.appriseOuter').width() ) / 2+$(window).scrollLeft() + "px");
            
            if(
        args)
                {
                if(
        args['animate'])
                    { 
                    var 
        aniSpeed args['animate'];
                    if(
        isNaN(aniSpeed)) { aniSpeed 400; }
                    $(
        '.appriseOuter').css('top''-200px').show().animate({top:"100px"}, aniSpeed);
                    }
                else
                    { $(
        '.appriseOuter').css('top''100px').fadeIn(200); }
                }
            else
                { $(
        '.appriseOuter').css('top''100px').fadeIn(200); }
            
            if(
        args)
                {
                if(
        args['input'])
                    {
                    if(
        typeof(args['input'])=='string')
                        {
                        $(
        '.appriseInner').append('<div class="aInput"><input id="str" type="text" class="aTextbox" t="aTextbox" value="'+args['input']+'" /></div>');
                        }
                    else
                        {
                        $(
        '.appriseInner').append('<div class="aInput"><input id="str" type="text" class="aTextbox" t="aTextbox" /></div>');
                        }
                    $(
        '.aTextbox').focus();
                    }
                }
            
            $(
        '.appriseInner').append('<div class="aButtons"></div>');
            if(
        args)
                {
                if(
        args['confirm'] || args['input'])
                    { 
                    $(
        '.aButtons').append('<button value="ok">'+args['textOk']+'</button>');
                    $(
        '.aButtons').append('<button value="cancel">'+args['textCancel']+'</button>'); 
                    }
                else if(
        args['verify'])
                    {
                    $(
        '.aButtons').append('<button value="ok">'+args['textYes']+'</button>');
                    $(
        '.aButtons').append('<button value="cancel">'+args['textNo']+'</button>');
                    }
                else
                    { $(
        '.aButtons').append('<button value="ok">'+args['textOk']+'</button>'); }
                }
            else
                { $(
        '.aButtons').append('<button value="ok">Ok</button>'); }
            
            $(
        document).keydown(function(e
                {
                if($(
        '.appriseOverlay').is(':visible'))
                    {
                    if(
        e.keyCode == 13
                        { $(
        '.aButtons > button[value="ok"]').click(); }
                    if(
        e.keyCode == 27
                        { $(
        '.aButtons > button[value="cancel"]').click(); }
                    }
                });
            
            var 
        aText = $('.aTextbox').val();
            if(!
        aText) { aText false; }
            $(
        '.aTextbox').keyup(function()
                { 
        aText = $(this).val(); });
           
            $(
        '.aButtons > button').click(function()
                {
                $(
        '.appriseOverlay').remove();
                $(
        '.appriseOuter').remove();
                if(
        callback)
                    {
                    var 
        wButton = $(this).attr("value");
                    if(
        wButton=='ok')
                        { 
                        if(
        args)
                            {
                            if(
        args['input'])
                                { 
        callback(aText); }
                            else
                                { 
        callback(true); }
                            }
                        else
                            { 
        callback(true); }
                        }
                    else if(
        wButton=='cancel')
                        { 
        callback(false); }
                    }
                });
            } 
        Added after 21 minutes:

        oops will need to add <input type="button" onclick="addurl()" value="Add Url" /> into it also but that shouldnt be to hard :P
        Last edited by something else; 07.03.12, 14:57.

        Comment

        Working...
        X