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"/>
精彩评论