Good day.

There is a form calculator. With emailing.

There are three text fields in which three prices are displayed, there are three radio buttons that need to be associated with these fields.

If it is shorter: the calculator calculated for a person 3 prices, for 45, 60 and 90 minutes. A person must choose to choose one button, which must send the price to the post in 45, 60 or 90 min.

From one value parameter, the numbers must be transferred to another and sent to the mail.

  • Please write with what exactly or at what stage of the assignment you have difficulties - makregistr
  • There are three text fields <input type = "text" name = "m45" value = "0" /> <input type = "text" name = "m60" value = "0" /> <input type = "text" name = "m90" value = "0" /> Their value value appears after calculating the calculator. There are three radio buttons. The selected button is sent to the mail. <input type = 'radio' name = 'chb []' value = "0" /> 45 Minutes <input type = 'radio' name = 'chb []' value = "0" /> 60 Minutes <input type = 'radio' name = 'chb []' value = "0" /> 90 Minutes I need the value of the text field to be displayed in the radio button. So that when a button is selected, only one of three prices is sent. - AubakirovAlex
  • I read somewhere that you need to dig in the direction of onchange = "" you can explain - AubakirovAlex

1 answer 1

Specifically on the issue, start from here . And then about onchange ...

upd Well what you do yourself. Seriously.

Do not appear in the user interface for radio buttons. The value property only has meaning when submitting a form. It is not a list of informations sent by the radio.

All three and will not be sent. Same radio, they have one name, it means that the value that is selected will be sent. Specify the value for the radio button and that's it.

upd2 . re-read the comment. value, which is considered to be yours and you write it in the input type="text" 's write to the values ​​of these radio buttons. For radio buttons it is necessary to establish compliance with the prices. set id for them, for example:

 <input type="radio" name="chb[]" id="r45" value="0"> <input type="radio" name="chb[]" id="r60" value="0"> <input type="radio" name="chb[]" id="r90" value="0"> 

when calculating, write in them the corresponding values ​​in the script:

 document.getElementById('r45').value = 1000; document.getElementById('r60').value = 1500; document.getElementById('r90').value = 2000; 

when sending a form, on the server, catch what is written in chb [], there will be a selected price.

  • The suspicion was not justified. The form is self-written, for me I do not ask. Everything works already. I just want to make sure that only the selected price is sent. And not all three. - AubakirovAlex
  • So, here neponyatki. And judging by the answer, you seem to understand me the opposite. According to your design, when you click on the radio button, 1000,1500,2000 should appear in the text field. And it is necessary that from the three text fields sent what I chose, through a radio button. Here is this form aubakirovalexandr.com/index.php - AubakirovAlex
  • that's right Your test fields display a value for the user. and it is necessary to send to the server what is written in the radio, so it will be more logical. [your form] [1]. Corrected slightly html, added <label> for radio buttons. [1]: jsfiddle.net/ivanovsuper/Pk4A4 - Yura Ivanov
  • Everything is working. Thank you so much. - AubakirovAlex
  • If you do not make it difficult, you can say whether it is possible to transmit the radio buttons with the digital value and value = "". to allow "Price 5000r For 90 minutes" <input type = "radio" name = "chb []" id = "r90" value = "For 90 minutes"> - AubakirovAlex