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 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

Heyy can somebody help me ? i have this issue that still do know
I'm having an issue that I can't seem to solve myself. I have the
I'm having a validation issue that I can't figure out. I know I have
I have an issue that I can't seem to solve. I am randomly generating
I have an issue that I can't solve by myself. The best thing would
I have an issue that is driving me nuts and hoping someone can help.
Happy New Year SO users! I have an issue that I hope someone can
I have an issue in that a Symfony2 form can pass validation but still
I have an nHibernate query issue that looks quite straight forward, but I can't
I have list of screen names that can be filtered by letter. The Issue

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.