Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

determine value of hidden field from user input

Participant ,
Aug 27, 2010 Aug 27, 2010

Copy link to clipboard

Copied

I have a form and a user types in an asking price for an item.

I want to have a hidden field determine a value of .75 times the value of the asking price field.

the form will input the information into a MYSQL database.

How do i arrive at the hidden field value based on the user input into the asking price field?

Thanks for your help,

Jim Balthrop

TOPICS
Server side applications

Views

636
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Aug 28, 2010 Aug 28, 2010

Copy link to clipboard

Copied

If you're going to use the hidden field as the field that inserts the resulting value into the database, then this has to be done before the page is submitted. It may work with javascript and the onChange event of the input field, perform the calculation and set the value of the hidden field.

Or you could modify the insert code and woulnd't need the hidden field. Redefine the form field variable with the calcuation before the actual insert, and use the input field as the one that send the value to the database,

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 28, 2010 Aug 28, 2010

Copy link to clipboard

Copied

thanks for your response,

I needed both inputs to be inserted into the database. I tried different coding for the insert command but could not get it to work (but it probably could be done that way).

I found a way to do it with jQuery.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"...

<script language="javascript" type="text/javascript">

function calculateHiddenValue () {

      var newvalue = $(this).val() * .75;

      $('#hiddenField2auctionopen').val(newvalue);

}

$(document).ready(function() {

      $('#v_ask_price').keyup(calculateHiddenValue);

});

</script>

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Aug 28, 2010 Aug 28, 2010

Copy link to clipboard

Copied

LATEST

I did wonder if you needed to insert both values.

Very creative solution - Thank you for sharing it!

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines