开发者

combine a fixed value (from drop down box)+ suffix (value input by user) and put this value into a text box in a form on same page

开发者 https://www.devze.com 2023-03-16 05:54 出处:网络
I have a requirement in a jsp web app, where a URL is taken as input from end user. This URL comprises of a fixed value (a list of possible url values from database that can\'t be changed by end user)

I have a requirement in a jsp web app, where a URL is taken as input from end user. This URL comprises of a fixed value (a list of possible url values from database that can't be changed by end user) and a suffix (for url) that can be input开发者_开发百科 by end user.

I want this fixed + suffix value to be populated into a text box in a form on same web page. How do I do this? Also I want to ensure that the text box in which the final value is populated, is non editable.

Can the above be done using an HTML form? I would appreciate it if you could provide a code sample.


   <html>
    <head>
      <script>
     function populateTxtFiled(){
      var url = document.getElementById('url');
      alert(url.value)
      document.getElementById('websiteUrl').value = "htttp://www."+url.value;
      document.getElementById('websiteUrl').disabled =true;

          }

  </script>
   </head>


 <body>
Select Website: 
<select id="url" onchange="populateTxtFiled()">
    <option value="0">select website url</option>
    <option value="google.com">google</option>
    <option value="yahoo.com">yahoo</option>
    <option value="youtube.com">youtube</option>
  </select>
<br />
<br />
Website Url<input  id="websiteUrl" type="text" name="websitUrl"/>

0

精彩评论

暂无评论...
验证码 换一张
取 消