Click here to Skip to main content
16,004,574 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: toLocaleString() works to insert commas in a asp.net textbox until I enter the eighth digit. The eight digit breaks the insertion of commas Pin
fig000018-Jul-24 20:02
fig000018-Jul-24 20:02 
QuestionCan we use the NuGet package of .Net in WebDriverIO (JavaScript) framework? Pin
Anand Sabley20-Jun-24 20:44
Anand Sabley20-Jun-24 20:44 
QuestionProgressbar has a value of 100% before upload progress is finished Pin
Red Kipling4-Jun-24 9:34
Red Kipling4-Jun-24 9:34 
AnswerRe: Progressbar has a value of 100% before upload progress is finished Pin
Richard Andrew x648-Jun-24 11:33
professionalRichard Andrew x648-Jun-24 11:33 
GeneralRe: Progressbar has a value of 100% before upload progress is finished Pin
Richard Deeming9-Jun-24 21:39
mveRichard Deeming9-Jun-24 21:39 
AnswerRe: Progressbar has a value of 100% before upload progress is finished Pin
jschell12-Jun-24 15:04
jschell12-Jun-24 15:04 
AnswerRe: Progressbar has a value of 100% before upload progress is finished Pin
Steve Raw17-Jun-24 10:34
professionalSteve Raw17-Jun-24 10:34 
QuestionProgressbar get only the size of first input Pin
Red Kipling2-Jun-24 0:43
Red Kipling2-Jun-24 0:43 
I have to add progressbar to kleeja upload script
I have a three inputs wich contain the files to upload
this is the css code for progressbar

CSS
#progress-bar {
            width: 100%;
            background-color: #f3f3f3;
        }
        #progress {
            width: 0%;
            height: 30px;
            background-color: #4caf50;
            text-align: center;
            line-height: 30px;
            color: white;
        }


and this is the javascript code
JavaScript
function uploadFile() {
    const fileInput = document.getElementById('file1');
    const fileInput2 = document.getElementById('file2');

    const file = fileInput.files[0];
    const file2 = fileInput2.files[1];
    

    const xhr = new XMLHttpRequest();
    xhr.open('POST', '/index.php', true);
    
    xhr.upload.onprogress = function (event) {
        if (event.lengthComputable) {
            const percentComplete = (event.loaded / event.total) * 100;
            const progress = document.getElementById('progress');
            progress.style.width = percentComplete + '%';
            progress.textContent = Math.round(percentComplete) + '%';
        }
    };

    xhr.onload = function () {
        if (xhr.status === 200) {
            alert('File uploaded successfully.');
        } else {
            alert('Error uploading file.');
        }
    };

    const formData = new FormData();
    formData.append('file1,file2', file);
    xhr.send(formData);
}

i save this file in folder 'progressbar'

this is the form to submit for uploading

PHP
<pre> <form id="uploader" action="<?=$this->vars['action']?>" method="post" enctype="multipart/form-data">


        <div class="card text-center">
            <div class="card-header">
                <ul class="nav nav-tabs card-header-tabs">
                    <li class="nav-item">
                        <a class="nav-link active" data-toggle="tab" href="#fileUpload" role="tab"><?=$this->vars['lang']['DOWNLOAD_F'] ?? '{lang.DOWNLOAD_F}'?></a>
                    </li>
                </ul>
            </div>
            <div class="card-body tab-content">

                <?php if($this->vars['config']['safe_code']){ ?>
                    <!-- verification code -->
                    <div class="safe_code card">
                        <div class="card-body">
                            <h4 class="card-title"><?=$this->vars['lang']['VERTY_CODE'] ?? '{lang.VERTY_CODE}'?></h4>
                            <h6 class="card-subtitle mb-2 text-muted"><?=$this->vars['lang']['NOTE_CODE'] ?? '{lang.NOTE_CODE}'?></h6>
                            <p class="card-text">
                                <img style="vertical-align:middle;" id="kleeja_img_captcha" src="<?=$this->vars['captcha_file_path']?>" alt="<?=$this->vars['lang']['REFRESH_CAPTCHA'] ?? '{lang.REFRESH_CAPTCHA}'?>" title="<?=$this->vars['lang']['REFRESH_CAPTCHA'] ?? '{lang.REFRESH_CAPTCHA}'?>" onclick="javascript:update_kleeja_captcha('<?=$this->vars['captcha_file_path']?>', 'kleeja_code_answer');" />
                                <input type="text" name="kleeja_code_answer" id="kleeja_code_answer" />
                            </p>
                        </div>
                    </div>
                <?php } ?>


                <!-- files upload  -->
                <div class="tab-pane active" id="fileUpload" role="tabpanel">

                  <?php foreach($this->vars["FILES_NUM_LOOP"] as $key=>$value){ ?>

                    <div class="input-group mb-2" style="" id="file-block-<?=$value['i']?>" onclick="document.getElementById('file<?=$value['i']?>').click();">
                        
                            <div class="btn btn-primary file-button-browse">
                                <img src="<?=$this->vars['STYLE_PATH']?>images/folder.png" width="20" height="20">
                                <?=$this->vars['lang']['OPEN'] ?? '{lang.OPEN}'?>
                            </div>
                        
                        <input type="file" class="example" name="file_<?=$value['i']?>_" id="file<?=$value['i']?>" data-number="<?=$value['i']?>" style="display:none" >
                        <input type="text"  id="file-text<?=$value['i']?>" disabled="disabled" placeholder="<?=$this->vars['lang']['NO_FILE_SELECTED'] ?? '{lang.NO_FILE_SELECTED}'?>" class="form-control">
                    </div>

                    <?php 
                
               
                
                } ?>

                    <div>
                        <br>
                        <div class="agree text-muted"><small><?=$this->vars['terms_msg']?></small></div>
                        <input type="submit" id="submitr" onclick="uploadFile()" name="submitr" value="<?=$this->vars['lang']['DOWNLOAD_F'] ?? '{lang.DOWNLOAD_F}'?>" class="btn btn-outline-primary">
                    </div>

                </div>
            </div>
        </div>

       
        <script src="progressbar/progress.js"></script>



    </form>


how can i modify the codes to make the progressbar show the three files upload progress

Thanks a lot
QuestionJqxTree control is taking time to load with 500 records Pin
yadta6-Feb-24 18:57
yadta6-Feb-24 18:57 
AnswerRe: JqxTree control is taking time to load with 500 records Pin
Richard Deeming6-Feb-24 21:33
mveRichard Deeming6-Feb-24 21:33 
GeneralRe: JqxTree control is taking time to load with 500 records Pin
jschell7-Feb-24 5:40
jschell7-Feb-24 5:40 
AnswerRe: JqxTree control is taking time to load with 500 records Pin
Prestige Somerville live27-Mar-24 20:10
Prestige Somerville live27-Mar-24 20:10 
Questionpassing 0 to a function Pin
mike741112-Jan-24 1:53
mike741112-Jan-24 1:53 
AnswerRe: passing 0 to a function Pin
Richard Deeming12-Jan-24 2:14
mveRichard Deeming12-Jan-24 2:14 
AnswerRe: passing 0 to a function Pin
Richard MacCutchan12-Jan-24 3:08
mveRichard MacCutchan12-Jan-24 3:08 
GeneralRe: passing 0 to a function Pin
mike741112-Jan-24 10:00
mike741112-Jan-24 10:00 
GeneralRe: passing 0 to a function Pin
Dave Kreskowiak12-Jan-24 12:46
mveDave Kreskowiak12-Jan-24 12:46 
GeneralRe: passing 0 to a function Pin
Richard MacCutchan12-Jan-24 22:08
mveRichard MacCutchan12-Jan-24 22:08 
GeneralRe: passing 0 to a function Pin
mike741113-Jan-24 0:48
mike741113-Jan-24 0:48 
GeneralRe: passing 0 to a function Pin
Richard MacCutchan13-Jan-24 1:55
mveRichard MacCutchan13-Jan-24 1:55 
GeneralRe: passing 0 to a function Pin
Dave Kreskowiak13-Jan-24 3:52
mveDave Kreskowiak13-Jan-24 3:52 
AnswerRe: passing 0 to a function Pin
Jeremy Falcon31-Jan-24 7:14
professionalJeremy Falcon31-Jan-24 7:14 
QuestionHow to Reference a local image file to display it Pin
Tom Mort31-Dec-23 7:00
Tom Mort31-Dec-23 7:00 
AnswerRe: How to Reference a local image file to display it Pin
Richard MacCutchan31-Dec-23 21:42
mveRichard MacCutchan31-Dec-23 21:42 
GeneralRe: How to Reference a local image file to display it Pin
Tom Mort1-Jan-24 6:17
Tom Mort1-Jan-24 6:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.