Jump to content
flavio_jeronimo

[Resolvido]Numeric up/down

Recommended Posts

flavio_jeronimo

Boas tardes ando a criar um numeric up/down, que por sua vez ja esta funcional, o que eu necessitava agora era de restringir os números entra 1 e 20, só que não sei como fazer, quem me puder dar uma luzes agradeço.

<html>
<head>

<title>numeric up/down</title>

</head>

<body>
<form method="post" action="">
numero de bilhetes que pretendes <input type="text" name="num" id="nume" size="10" value="1">

<input type="button" value="up" onclick="this.form.num.value++"><input type="button" value="down" onclick="this.form.num.value--" readonly="readonly">
</form>
</body>
</html>

Share this post


Link to post
Share on other sites
herty

Simples basta acrescentares um if nos eventos...

<html>
<head>

<title>numeric up/down</title>

</head>

<body>
<form method="post" action="">
numero de bilhetes que pretendes <input type="text" name="num" id="nume" size="10" value="1">

<input type="button" value="up" onclick="if(this.form.num.value<20)this.form.num.value++">
<input type="button" value="down" onclick="if(this.form.num.value>1)this.form.num.value--" readonly="readonly">
</form>
</body>
</html>

Share this post


Link to post
Share on other sites
malainhocf

Código errado:

<form method="post" action="">
numero de bilhetes que pretendes <input type="text" name="num" id="nume" size="10" value="1">

<input type="button" value="up" onclick="this.form.num.value++"><input type="button" value="down" onclick="this.form.num.value--" readonly="readonly">
</form>

Esse código está errado, deves fazer assim:

<form method="post" action="">

<label>numero de bilhetes que pretendes</label>

<input type="text" name="num" id="nume" size="10" value="1" />

<input type="button" value="up" onclick="this.form.num.value++" />

<input type="button" value="down" onclick="this.form.num.value--" readonly="readonly" />

</form>

Isso é que é correcto conforme os webstandards.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.