Jump to content

Incremental form box


chao

Recommended Posts

<html>
<head>
<script type="text/javascript">

function addValue(fieldID, addAmount)
{
    var fieldObj = document.getElementById(fieldID);
    var newValue = (parseInt(fieldObj.value) + addAmount);
    fieldObj.value = (newValue<0) ? 0 : newValue;
    return;
}

</script>
</head>

<body>
Count: <input type="text" name="count" id="count" readonly="readonly" value="5" />
<button onclick="addValue('count', 1)">+1</button>
<button onclick="addValue('count', -1)">-1</button>
<br /><br />
<button type="submit">Submit</button>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/134701-incremental-form-box/#findComment-701607
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.