Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1074065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:04:26+00:00 2026-05-16T21:04:26+00:00

What i am trying to achieve is adding the javascript loops and the named

  • 0

What i am trying to achieve is adding the javascript loops and the named variables into an sql database, some of them are already added to an external script so work fine however some which i have named in the SQL script at the bottom still need adding, however as the database won’t accept a colon “:” they won’t enter it and is returning an error, looking at the code at the bottom with replace function im sure you can see what i am trying to achieve but failing miserably, help is much appreciated!

window.status = 'Loading contingency scripts - please wait...';
audit('Loading contingency scripts');
var conting = {
    i: 0,
    start: function() {
        window.status = 'Loading form - please wait...';
        var t = '';
        t += '<form name="frm_conting" id="frm_conting" onsubmit="return false;">';
        t += '<table width="100%" cellspacing="1" cellpadding="0">';
        t += '<tr><td>Date (DD/MM/YY):</td><td><input type="text" size="8"    value="' + current_date + '" id="date"></td></tr>';

        t += '<tr><td>Time Started:</td><td><select id="timefrom"><option></option>';
        for (h = 8; h < 23; h++) {
            for (m = 0; m < 46; m = m + 15) {
                t += '<option value=' + nb[h] + ':' + nb[m] + '>' + nb[h] + ':' + nb[m] + '</option>';
            };
        };
        t += '</select></td></tr>';

        t += '<tr><td>Time Finished:</td><td><select id="timeto"><option></option>';
        for (h = 8; h < 23; h++) {
            for (m = 0; m < 46; m = m + 15) {
                t += '<option value=' + nb[h] + ':' + nb[m] + '>' + nb[h] + ':' + nb[m] + '</option>';
            };
        };

        t += '</select><tr><td>Extension #:</td><td><input type="text" size="5" value="' + my.extension + '" id="staffid"></td></tr>';
        t += '<tr><td>Desk ID:</td><td><input type="text" size="5" value=' + my.deskid + ' id="desk"></td></tr>';
        t += '<tr><td>Number of calls:</td><td><input type="text" size="5" id="calls"></td></tr>';
        t += '<tr><td>Avid ID:</td><td><input type="text" size="5" id="avid"></td></tr>';
        t += '<tr><td><input type="button" value="Submit" onClick="conting.save()"></td>';
        t += '</table>';
        t += '</form>';

        div_form.innerHTML = t;
        window.resizeTo(400, 385);
        window.status = '';
    },

    save: function() {
        var conting_date = frm_conting.date.value;
        if (!isdate(conting_date)) {
            alert("You have entered an incorrect date.");
            return false;
        };

        var conting_timefrom = frm_conting.timefrom.value;
        var conting_timeto = frm_conting.timeto.value;
        if (conting_timefrom == '' || conting_timeto == '') {
            alert("You need to enter a starting & finishing time.");
            return false;
        };
        if (conting_timefrom > conting_timeto) {
            alert("The time you have entered is after the finish time.");
            return false;
        };

        var conting_staffid = frm_conting.staffid.value;
        if (conting_staffid.length != 5) {
            alert("You have entered an incorrect extension number.");
            return false;
        };

        var conting_desk = frm_conting.desk.value;
        if (conting_desk.length != 5) {
            alert("You have entered an incorrect desk ID.");
            return false;
        };

        var conting_calls = frm_conting.calls.value;
        if (isNaN(conting_calls)) {
            alert("You have not entered amount of calls.");
            return false;
        };

        var conting_avid = frm_conting.avid.value;
        if (isNaN(conting_avid)) {
            alert("You have entered an incorrect avid ID.");
            return false;
        };
        if (conting_avid.length != 5) {
            alert("You have entered an incorrect avid ID.");
            return false;
        };

        conn.open(db["contingency"]);
        rs.open("SELECT MAX(prac_id) FROM practice", conn);
        var prac_id = rs.fields(0).value + 1;
        var prac_timefrom = parseFloat(frm_conting.timefrom.value);
        var prac_timeto = parseFloat(frm_conting.timefrom.value);
        var prac_calls = frm_conting.calls.value;
        var prac_avid = frm_conting.avid.value;
        rs.close();
        var q = "INSERT INTO practice (prac_id, prac_staffid, prac_date, prac_timefrom, prac_timeto, prac_extension, prac_desk, prac_calls, prac_avid) VALUES (" + prac_id + "," + my.id + ", " + current_date + ", " + prac_timefrom + ", " + prac_timeto + ", " + my.extension + ", " + my.deskid + ", " + prac_calls + ", " + prac_avid + ")";
        var q = "UPDATE SELECT practice REPLACE ('isNaN', ':', 'isNull')"

        alert(prac_timefrom);
        rs.open(q, conn);
        conn.close();
    }


};
window.status = '';​
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T21:04:27+00:00Added an answer on May 16, 2026 at 9:04 pm

    This bit of code looks extremely dubious.

    var q = "INSERT INTO practice (prac_id, prac_staffid, prac_date, prac_timefrom, prac_timeto, prac_extension, prac_desk, prac_calls, prac_avid) VALUES (" + prac_id + "," + my.id + ", " + current_date + ", " + prac_timefrom + ", " + prac_timeto + ", " + my.extension + ", " + my.deskid + ", " + prac_calls + ", " + prac_avid + ")";
    var q = "UPDATE SELECT practice REPLACE ('isNaN', ':', 'isNull')"
    
    alert(prac_timefrom);
    rs.open(q, conn);
    
    1. you should use parameterised queries to avoid SQL injection. Additionally even without any deliberate SQL injection attempts this code will fail if any of the form fields contain the ' character.

    2. You are assigning to the variable q twice and aren’t executing the result of the first assignment. (And declaring it twice actually?!)

    3. There is no syntax such as UPDATE SELECT it would need to be something like UPDATE practice SET SomeColumn = REPLACE (SomeColumn, 'isNaN', 'isNull') presumably except see 4 and 5.

    4. I’m not clear what the Replace is meant to be doing anyway. What are the 3 parameters you have given it?

    5. It would be better to do the Replace on the value before inserting into the database rather than inserting it wrong then updating it to the new value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to achieve adding the animated gifs into my application. 1- I
I'm trying to pre-sort an array of items are added into an array using
I have trying to achieve SVG element's animation while adding dynamic DOMs for its
Trying to achieve any moving effect while appending an element from one to another
im trying to achieve something but i dont really know how I have set
What I'm trying to achieve is show count of lines starting with/ending with needle
What i'm trying to achieve is playing a guitar chord from my python application.
What I'm trying to achieve is: Let inflector slug Ignore a special character in
I am trying to achieve an effect of overlapping the main window boundary with
What I am trying to achieve is editing code in vim then running make

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.