Jump to content

Automatically update textbox?


Roy766

Recommended Posts

I'm sorry if I have to use some other language. If so, could a mod please move this?

 

Anyways, I've got a couple of text boxes on my page, and I want it so that there's another text box that automatically updates when one of the other text boxes changes. Any suggestions on how to do this?

Link to comment
Share on other sites

Yes, this will need javascript. Basically have a function that you can call and when input is made(onkeypress or whatever), you call the function with the current input field's properties, and then to your comparisons or whatever. Then, say, if your textarea you want updated has a name="txt" in a form name="form1", then you'd do document.form1.txt.value='value goes here';

 

that's the gist of it

Link to comment
Share on other sites

I'm pretty sure I already showed him how to do it.

 

Also making a function and using form names as objects is much bulkier then my solution.

 

You only have 8 posts here. So you obviously haven't experienced where you give someone a clean-cut, simple answer and they manage to have trouble with it. There's nothing "bulky" about my response. Yea, if you're including several js files that are huge then it'd be bad, but when it comes to basic js, performance isnt even a nanosecond slower than your code. And if he wants to do further calcuation or comparison of the input, you really think it's better(and cleaner) to put it all within the quotes after the event handler(onchange)? How about no.

 

Plus, your code doesn't do what he asks. He asks for the textbox to update as input is typed. Your example gives the change after leaving the current input field. The correct one would be onkeyup instead of onchange

Link to comment
Share on other sites

1.How would I know the old experienced vs. non-experienced forum member argument would be pulled? *sigh*

 

2.Anyway, I am a paid moderator at other php help forum sites, so I think I know how to deal with answering questions.

 

3.Your code is not "bulky", it's "bulkier".  ;)

 

4.Lastly, I am sorry Roy766 that you had to see this argument in a thread about you, but if you want other textboxes to change in realtime, yes use onkeydown/onkeypress etc.

Link to comment
Share on other sites

 

2.Anyway, I am a paid moderator at other php help forum sites

 

 

then go to them. You're like the customer that says "Well, so and so restaurant love me and always give me a free dessert on my birthday" and to them, I say 'well why dont you go there???'

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.