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 3780580
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T10:50:08+00:00 2026-05-19T10:50:08+00:00

I have an issue that I can’t solve (I don’t know how cause I’m

  • 0

I have an issue that I can’t solve (I don’t know how cause I’m a newbie in php and js). I have a text field and I want on blur trigger a function in js. My problem is that I want to pass a parameter in tnis function, which will get from a query.
My test code is :

<script type="text/javascript">
  function calcNums(nums){
    var inText = "00.00";
    if (document.expences.mytext.value != inText){
    var mp = parseInt(nums.substr(0,2));
    var lp = parseInt(nums.substr(3,2));
    document.expences.mytext2.value = lpdeh*parseInt(document.expences.mytext.value)/100; 
    document.expences.mytext.value = mpdeh*parseInt(document.expences.mytext.value)/100; 
    } 
  }
</script>

<?php

    $selNums = "SELECT DEH_NUMS FROM BUILDING WHERE idBUILDING = '3'";
    $nums = mysql_query($selNums) or die("Could not execute query.");
    <input type="text" name="mytext" id="mytext"  value="00.00" onblur="calcNums($nums)"/>
    <input type="text" name="mytext2" id="mytext2"  value="00.00"/>
?> 

My point is : I get $nums that is of type ’50-50′ (represents percentages). Get the initial value of “mytext” and calculate new values for “mytext” and “mytext2”.
example : $nums=’60-40′ initialMytext=100 –> new mytext=60 mytext2=40

If I put an inner var in calcNums() calculations are correct, but with the parameter is not triggered.

Can someone help?
Thanks in advance!

  • 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-19T10:50:08+00:00Added an answer on May 19, 2026 at 10:50 am

    write this and it will fix

    <script type="text/javascript">
      function calcNums(nums){
        var inText = "00.00";
        if (document.expences.mytext.value != inText){
        var mp = parseInt(nums.substr(0,2));
        var lp = parseInt(nums.substr(3,2));
        document.expences.mytext2.value = lpdeh*parseInt(document.expences.mytext.value)/100; 
        document.expences.mytext.value = mpdeh*parseInt(document.expences.mytext.value)/100; 
        } 
      }
    </script>
    
    <?php
        $selNums = "SELECT DEH_NUMS FROM BUILDING WHERE idBUILDING = '3'";
        $results = mysql_query($selNums);
        if (!$results) die("Could not execute query.");
    
        $row = mysql_fetch_assoc($results);
        $nums = $row['DEH_NUMS'];
    ?>
    <input type="text" name="mytext" id="mytext"  value="00.00" onblur="calcNums('<?php echo $nums;?>')"/>
    <input type="text" name="mytext2" id="mytext2"  value="00.00"/> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an issue that I can't seem to solve. I am randomly generating
I have: image 1:Many imageToTag Many:1 tag I want to issue a query that
I have a perplexing issue that I can't seem to comprehend... I have two
I have an issue that is driving me a bit nuts: Using a UserProfileManager
I have a database issue that i currently cannot wrap my head around with
I have a weird issue that only seems to be affecting IE 7. The
I have a design issue that I would appreciate some input on. I would
An odd issue that I have been trying to address in a project -
After being troubled by an issue that I simply did not have the knowledge
Here's the issue: I have a hook in IE that reacts on WebBrowser.OnNavigateComplete2 event

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.