Roy766 Posted July 9, 2008 Share Posted July 9, 2008 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? Quote Link to comment Share on other sites More sharing options...
Third_Degree Posted July 9, 2008 Share Posted July 9, 2008 yes <input type="text" onchange="javascript: document.getElementById('other').value=this.value" /><br /> <input type="text" id="other" /> Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted July 9, 2008 Share Posted July 9, 2008 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 Quote Link to comment Share on other sites More sharing options...
Third_Degree Posted July 9, 2008 Share Posted July 9, 2008 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. Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted July 9, 2008 Share Posted July 9, 2008 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 Quote Link to comment Share on other sites More sharing options...
Third_Degree Posted July 9, 2008 Share Posted July 9, 2008 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. Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted July 10, 2008 Share Posted July 10, 2008 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???' Quote Link to comment Share on other sites More sharing options...
Third_Degree Posted July 10, 2008 Share Posted July 10, 2008 I wasn't trying to be mean when I posted what I did. This community seems friendly, helpful, and (most importantly) large. I have nothing against this site or you, I just really enjoy coding, and would like to become involved in these boards. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.