What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Dynamically changing text box, based on a form input?

Dynamically changing text box, based on a form input?
Author: Message:
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
35 / Male / Flag
Joined: Aug 2006
RE: Dynamically changing text box, based on a form input?
Use a javascript event...

Javascript code:
//define this function somewhere
function roundNumber(num, dec) {
    var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
    return result;
}
 
// x = amount (6.23 for example)
this.value = roundNumber(x / 0.05, 2);
 


I think that should do it... You should know roughly what to do with the code

EDIT: An untested example...

Javascript code:
<form name="MyForm" action="https://www.paypal.com/cgi-bin/webscr" method="post">
  <fieldset>
    <label for="amount">$</label>
    <input id="amount" name="amount" value="5.00" onchange="var id=document.getElementById('result');id.value='Result: $'+Math.round(((this.value*1)/0.05)*Math.pow(10,2))/Math.pow(10,2)"/>    <label for="custom">Steam ID:</label>
    <input id="custom" name="custom" value="<?php echo strstr(curPageURL(), 'STEAM_');?>" />
    <input name="business" type="hidden" value="******************" />
    <input name="cmd" type="hidden" value="_xclick" />
    <input name="currency_code" type="hidden" value="USD" />
    <input name="item_name" type="hidden" value="vip" />
    <input name="no_note" type="hidden" value="1" />
    <input name="no_shipping" type="hidden" value="1" />
    <input src="http://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" type="image" alt="Click here to donate">
   
  </fieldset>
</form>
 
<div id="result"></div>


This post was edited on 02-08-2010 at 12:21 AM by Spunky.
<Eljay> "Problems encountered: shit blew up" :zippy:
02-07-2010 11:44 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Dynamically changing text box, based on a form input? - by Jimbo on 02-07-2010 at 09:37 PM
RE: Dynamically changing text box, based on a form input? - by Chrissy on 02-07-2010 at 10:07 PM
RE: Dynamically changing text box, based on a form input? - by stoshrocket on 02-07-2010 at 10:14 PM
RE: Dynamically changing text box, based on a form input? - by Jimbo on 02-07-2010 at 11:03 PM
RE: Dynamically changing text box, based on a form input? - by Spunky on 02-07-2010 at 11:44 PM
RE: Dynamically changing text box, based on a form input? - by Jimbo on 02-08-2010 at 12:15 AM
RE: Dynamically changing text box, based on a form input? - by Spunky on 02-08-2010 at 12:22 AM
RE: Dynamically changing text box, based on a form input? - by stoshrocket on 02-08-2010 at 12:36 AM
RE: Dynamically changing text box, based on a form input? - by Jimbo on 02-08-2010 at 12:37 AM
RE: Dynamically changing text box, based on a form input? - by Spunky on 02-08-2010 at 12:40 AM
RE: Dynamically changing text box, based on a form input? - by Jimbo on 02-08-2010 at 01:08 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On