Currently I have a donation system that does this.
[code]<form id="donationDetails">
<select name="amount" width="300" style="width: 300px">
<option value="100">$100</option>
<option value="50">$50</option>
<option value="20">$20</option>
<option value="15">$15</option>
<option value="10" selected="selected">$10</option>
<option value="5">$5</option>
<option value="2">$2</option>
<option value="1">$1</option>
</select>
<input type="hidden" name="item_name" value="Donation" />
</form>[/code]
I'm trying to make it so that [code]<input type="hidden" name="item_name" value="Donation" />[/code] changes based on the value selected, so i.e selecting the $15 option will make it
[code]<input type="hidden" name="item_name" value="15$ Donation" />[/code], or something of the like.
Spent quite a while looking at stuff like [url]http://stackoverflow.com/questions/5629263/option-in-dropdown-box-that-changes-an-input-box[/url] and am still a noob and unable to get this to work correctly. Please help :S
Why not just use the value of the select element?
[QUOTE=Shadow801;39978279]Why not just use the value of the select element?[/QUOTE]
My other script uses the item name that is given through Paypal IPN, it's easier for me to figure a way to do it this way, than edit the IPN script, database files, and ingame checker.
Wow, what a dumb script. But why don't you do <option value="$5 Donation">$5</option> then? With the <select> having the name item_name?
If you must use JS (yeah right) you can do something similar to this in jQuery (when the DOM is ready): [code]$("select[name=amount]").change(function() { $("input[name=item_name]").val("$" + $(this).val() + " Donation"); }); [/code]
[QUOTE=SteveUK;39978311]Wow, what a dumb script. But why don't you do <option value="$5 Donation">$5</option> then? With the <select> having the name item_name?
If you must use JS (yeah right) you can do something similar to this in jQuery (when the DOM is ready): [code]$("select[name=amount]").change(function() { $("input[name=item_name]").val("$" + $(this).val() + " Donation"); }); [/code][/QUOTE]
I suppose. I didn't write the script, but what do you mean by "With the <select> having the name item_name?"?
[QUOTE=Lerpaderp;39978598]I suppose. I didn't write the script, but what do you mean by "With the <select> having the name item_name?"?[/QUOTE]
I guess he meant that it's simpler to do it this way:
[CODE]
<form id="donationDetails">
<select name="item_name" width="300" style="width: 300px">
<option value="100">$100</option>
<option value="50">$50</option>
<option value="20">$20</option>
<option value="15">$15</option>
<option value="10" selected="selected">$10</option>
<option value="5">$5</option>
<option value="2">$2</option>
<option value="1">$1</option>
</select>
</form>
[/CODE]
[editline]20th March 2013[/editline]
I don't see any reason to use hidden input and some jQuery when this is easier way to implement. Unless for some unknown reason the script itself needs the form to be like what you posted here.
[QUOTE=SteveUK;39978311]Wow, what a dumb script. But why don't you do <option value="$5 Donation">$5</option> then? With the <select> having the name item_name?
If you must use JS (yeah right) you can do something similar to this in jQuery (when the DOM is ready): [code]$("select[name=amount]").change(function() { $("input[name=item_name]").val("$" + $(this).val() + " Donation"); }); [/code][/QUOTE]
Paypal will not read the amount value for some reason, that way.
Sorry, you need to Log In to post a reply to this thread.