Can you make spinner buttons in PHP?

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Post Reply
User avatar
OldRod
Posts: 1320
Joined: Sun Sep 20, 2009 4:26 pm

Can you make spinner buttons in PHP?

Post by OldRod »

I've been looking and can't find any examples of using spinner buttons on a form with PHP.

Anyone done this? Does it require javascript? Or can it be done in PHP?
User avatar
OldRod
Posts: 1320
Joined: Sun Sep 20, 2009 4:26 pm

Re: Can you make spinner buttons in PHP?

Post by OldRod »

Ok, I found an example using JS, but I can't get it to work.

Here's the code I'm trying (snipped from a larger part obviously):

Code: Select all

<td rowspan=2>Strength: <input type="text" name="str" value=20 size=2></td>
<td><input type="button" value="+" onclick="this.form.str.value++;"></td>
<td><input type="button" value="-" onclick="this.form.str.value--;"></td>
It looks fine on screen, but clicking the button does nothing.

Do I need to do something to activate the code somehow? I've never tried putting Javascript inside of form element before so there's probably something I'm missing.
Falken
Posts: 438
Joined: Fri May 08, 2009 8:03 pm

Re: Can you make spinner buttons in PHP?

Post by Falken »

You can try this:

Give the text field an ID, like this

Code: Select all

<input type="text" value="" id="myBox" />
And to change the value of the box with a button

Code: Select all

<input type="button" value="Hello" onClick="javascript: document.getElementById('myBox').value = 'hello world';" />
Use that and you can probably make your own spin box
--- Game Database ---
For all your game information needs!
Visit us at: http://www.gamedatabase.eu today!
User avatar
OldRod
Posts: 1320
Joined: Sun Sep 20, 2009 4:26 pm

Re: Can you make spinner buttons in PHP?

Post by OldRod »

Code: Select all

<td><input type="text" id="str" value=20 size=2></td>
<td><input type="button" value="+" onclick="javascript: document.getElementById('str').value++;"></td>
This works - thanks Falken! It's not exactly what you posted, but it pointed me in the right direction :)
Post Reply

Return to “Advanced Help and Support”