Jump to content

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/116598-put-textfield-value-to-other-textfield/
Share on other sites

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.

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

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.