Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

change inpu type via php

General discussions related to php

Moderators: macek, egami, gesf

change inpu type via php

Postby JazzKatua » Thu Sep 13, 2012 7:01 am

Hi everybody!

I'm starting to learn PHP.
What I'm trying to do now is to have 2 input type textfields, 1 button and another input type 'Result'-textfield in HTML.
When clicking the button, the 'Result'-textfield should update the value with the sum of the 2 numbers I've typed in the first 2 textfields.
How can I achieve this?

Thx in advance!
JazzKatua
New php-forum User
New php-forum User
 
Posts: 1
Joined: Thu Sep 13, 2012 6:43 am

Re: change inpu type via php

Postby TomCornar » Sun Sep 16, 2012 10:58 pm

Try with js or jquery to sum up the two text box value to another textbox using onclick event.

<script type="text/javascript">
function sum()
{
var value1=document.getElementById('textone').value;
var value2=document.getElementById('texttwo').value;
document.getElementById('textthree').value=(value1*1)+(value2*1);
}
</script>
<form method="post" action="">
<input type="text" id="textone">
<input type="text" id="texttwo">
<input type="text" id="textthree">
<input type="submit" onclick="sum();">
</form>
Hope this Helps.
Regards,
Tom Cornar
Trinay Technology Solutions
http://www.trinay.com
User avatar
TomCornar
New php-forum User
New php-forum User
 
Posts: 25
Joined: Fri Sep 14, 2012 12:06 am


Return to PHP General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron