I want to populate my textbox with value from an element.
Perhaps my code will explain better:
This is in header.ascx
<form method="get" action="/_apps/results.aspx" onsubmit="if(this.elements['query'].value==''){ alert('Enter something.'); this.elements['query'].focus(); return false; } else { return true; }">
<td width="10%" class="navTopbarText">
<input type="hidden" name="type" id="type" value="banner"> <input type="text" alt="" size="20" maxlength="200" class="formTextboxText" name="query" value=this.elements['query'].value id="query">
</td>
</form>
This part doesn't work: value=this.elements['query'].value What should I replace this by? I would like the value to be what is in the element 'query'.
Thank you all.
I think your markup has several problems but what you ought to do is have an
<asp:textbox />
field and define a required field validator for it.Then you should remove the whole
onsubmit
function call from theform