Jump to content

ajax and php - change text field with a button


sugarcube

Recommended Posts

Hi guys,

 

I'have a problem. I want to change a field with a button.

my field: <input type=\"text\" name=\"invoerregel\"><br>

my button: <input type=\"button\"  name=\"1\"  value=\"1\">

 

now is my question, how can ik change my button so, that every time I push the button it adds a 1 to the text field



// add one (string)

<script type="text/javascript">

function addOne(){

    document.getElementById('myText').innerHTML+='1';

}//end function

</script>

<textarea id="myText"></textarea>
<br>
<button onclick="addOne();">Click Me!</button>


// add one (increment)

<script type="text/javascript">

function addOne(){

    var curVal=document.getElementById('myText').innerHTML*1;
    
    document.getElementById('myText').innerHTML=curVal+1;

}//end function

</script>

<textarea id="myText"></textarea>
<br>
<button onclick="addOne();">Click Me!</button>

 

Like so?

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.