Jump to content

How to Populate legend with text box value?


Guest Gloria

Recommended Posts

I am pretty new to web development and is still trying to figure out all the tweaks. I created a small HTML file as below. The document allows users to enter some text into the text box. It also has a submit button that will retrieve the data from the database and populate in the div section.My question is, how do I populate the value entered in the text box in the legend?<form> Name<input type =text id="txtName" name="txtName"> <input type="submit" value="Submit" name="B1" id="qry"></p></form><fieldset style="WIDTH: 100%; HEIGHT: 75%"><legend>txtName.value</legend><div id="divResults"></div></fieldset></body>Thanks.

Link to comment
Share on other sites

Hi Gloria, try this i think it's what you were asking for, works in both IE & FF.<head><script>function check(){content=document.getElementById('txtName').value;document.getElementById('lgd').innerHTML=content;return false;}</script></head><body><form onsubmit="return check()">Name<input type="text" id="txtName" name="txtName" /><input type="submit" value="Submit" name="qry" id="qry"></p></form><fieldset style="width:100%;height:75%"><legend id="lgd">txtName.value</legend><div id="divResults"></div></fieldset></body>

Link to comment
Share on other sites

Yes, check() is a javascript function, javascript can make web pages more interactive and less static.If your familiar with (X)HTML then your next step could be to learn a scripting language, i'd recommend you check out the free tutorials on the w3schools site here: http://www.w3schools.com/js/default.asp

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...