pfkdesign Posted July 25, 2008 Share Posted July 25, 2008 hi guys, i have a problem and perhaps you can help me ! ??? ??? i have a textfiled1 "Menu Name" and i have another textfield2 "URL" of the menu,by default the value of the url is /controller/ID/ (it is come from database) what i want is: when i'm writing in to text field ="label_mnu_1", text field = "url_link_mnu_1" get the value and change the url in to /controller/ID/value texfield1/ <label for="label_mnu_1"> Menu Name</label> <input type="text" name="label_mnu_1" value="" id="label_mnu_1"/> <label for="url_link_mnu_1">URL: </label> <input name="url_link_mnu_1" type="text" id="url_link_mnu_1" value="/controller/ID/$/" size="30"/> put value of label_mnu_1 here ^ any idea? thank you in advance Quote Link to comment https://forums.phpfreaks.com/topic/116598-put-textfield-value-to-other-textfield/ Share on other sites More sharing options...
KevinM1 Posted July 25, 2008 Share Posted July 25, 2008 hi guys, i have a problem and perhaps you can help me ! ??? ??? i have a textfiled1 "Menu Name" and i have another textfield2 "URL" of the menu,by default the value of the url is /controller/ID/ (it is come from database) what i want is: when i'm writing in to text field ="label_mnu_1", text field = "url_link_mnu_1" get the value and change the url in to /controller/ID/value texfield1/ <label for="label_mnu_1"> Menu Name</label> <input type="text" name="label_mnu_1" value="" id="label_mnu_1"/> <label for="url_link_mnu_1">URL: </label> <input name="url_link_mnu_1" type="text" id="url_link_mnu_1" value="/controller/ID/$/" size="30"/> put value of label_mnu_1 here ^ any idea? thank you in advance This isn't too hard: <script type="text/javascript"> window.onload = function() { var menuName = document.forms["formName"].elements["label_mnu_1"]; //formName is whatever name you've given the form var url = document.forms["formName"].elements["url_link_mnu_1"]; menuName.onblur = function() { url.value += this.value + '/'; } } </script> Like I wrote above, "formName" should be replaced by the actual name of the form inside your HTML. This code modifies the second text input's value when the first input is no longer focused on (i.e., no longer has the cursor). If you want this to be done based on a submit button being clicked, let me know. It's almost as easy. Quote Link to comment https://forums.phpfreaks.com/topic/116598-put-textfield-value-to-other-textfield/#findComment-599537 Share on other sites More sharing options...
pfkdesign Posted July 25, 2008 Author Share Posted July 25, 2008 wooow thank you so much, it works perfectly. exactly what i want. Quote Link to comment https://forums.phpfreaks.com/topic/116598-put-textfield-value-to-other-textfield/#findComment-599562 Share on other sites More sharing options...
pfkdesign Posted July 25, 2008 Author Share Posted July 25, 2008 is it possible to show the value on-demand ? ??? Quote Link to comment https://forums.phpfreaks.com/topic/116598-put-textfield-value-to-other-textfield/#findComment-599618 Share on other sites More sharing options...
lemmin Posted July 25, 2008 Share Posted July 25, 2008 <label for="label_mnu_1"> Menu Name</label> <input type="text" name="label_mnu_1" value="" id="label_mnu_1" onkeydown="url_link_mnu_1.value='/controller/ID/'+this.value"/> <label for="url_link_mnu_1">URL: </label> <input name="url_link_mnu_1" type="text" id="url_link_mnu_1" value="/controller/ID/" size="30"/> Just put the "/controller/ID/" text into the onkeydown event above the same way that you put it into the value of the input. Quote Link to comment https://forums.phpfreaks.com/topic/116598-put-textfield-value-to-other-textfield/#findComment-599633 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.