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

  • SEARCH
  • Home
  • 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 9199347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:30:56+00:00 2026-06-17T22:30:56+00:00

I have a function code like below function setShort() { var f = document.editFrm;

  • 0

I have a function code like below

function setShort() {
var f = document.editFrm;
var x = 10;
//var project_company = f.project_parent..value;
//project_name from database, 76 = project_parent's id
if (f.project_name.value.length < 11) {
    x = f.project_name.value.length;
}
if (f.project_short_name.value.length >= 0 && f.project_parent.value == 76) {
    var w = 0;
    var y = "UKSP-LC-12-"+(w+1);
    f.project_short_name.value = y;

    return w = w+1;
    //f.project_short_name.value = project_company;
}

this function is for selectlist, which mean if the user click the project_parent which id = 76, it will show to another textfield which is project_short_name.

So how can i code it let w cannot be repeated to 0 but can continue +1 after the first 0 saved, is it possible that use loop?

Or can i count the rows of the project parent so that i no need to use loop and just w(total rows of project_parent from sql)+1, im a newbie of loop and js, hope you guys have some ideas

  • 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-06-17T22:30:58+00:00Added an answer on June 17, 2026 at 10:30 pm

    Declare w outside the function:

    var w = 0;
    function setShort() {
        // ...
        // remove line below:
        // var w = 0; 
        // ....
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some javascript code like below function mask(eventVal,val){ var len = val.value.length; var
I have a code like below: var ws = new WebSocket(ws://localhost); ws.onopen = function()
I have some code like below $(html).on(change, input['data-href'], function() { var href, obj, params;
i have a javascript code like below function createArray() { var myArr = new
I have some code like below in an aspx page: function CheckEditing() { var
I have code like function populate...() { var user = $.storage.get(particulars); if (user) {
When we have code like: function a(){ var x =0; this.add=function(){ alert(x++); } }
I have code that looks like this: var baseClass = function() { // CODE
I have code like this in my view model: function ChatListViewModel(chats) { var self
I have code like this var MyObj = { f1 : function(o){ o.onmousedown =

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.