How Can I Use Functions in PHP Pages with Forms?

I have a html form on my php webpage. There are four input box. And I'm adding new data with these.

I want to do that, when I write something in input box1, input box2 will be same but with "-" instead of a space..

For example when I write "how are you" to input box1, input box2 must be "how-are-you".. How can I do that? :/

Upvotes: 0

Views: 80

Answers (3)

Hilmi
Hilmi

Reputation: 3441

just add this JavaScript on your page

   document.getElementById('box1').onkeyup = function (){
    document.getElementById('box2').value = document.getElementById('box1').value.replace(' ','-')
    }

Upvotes: 1

Mike Brant
Mike Brant

Reputation: 71422

You need to use javascript in order to do this without a page reload. PHP only operates on the server.

Upvotes: 0

Bob McCown
Bob McCown

Reputation: 127

You could do this with a simple bit of jQuery. When the text in the first box changes, set the text in the second box.

Upvotes: 0

Related Questions