hi to all
in my form there exist an hidden field. how to set a value to that field using javascript
regards
hi to all
in my form there exist an hidden field. how to set a value to that field using javascript
regards
Well In JavaScript -
<html>
<body>
<input type="hidden" id="hiddenbox">
<script>
document.onload=function() {
document.getElementById('hiddenbox').value="The Value Here"
}
</script>
</body>
</html>
In Plain HTML -
<html>
<body>
<input type="hidden" value="The Value Here" id="hiddenbox">
</body>
</html>
Hope This Helps...
thanks for your reply
i want to set the value hidden field when ever i click on a hyper link and also i want to set that hidden field value with this hyperlink value. is it possible.
regards
By value do you mean the href(address) or the text <a href="sadsasdsas.htm">WORDS</a>?
i want send text value
OK... -
<html>
<body onclick="setavalue()">
<a href="#">OK</a>
<a href="#">What</a>
<input type="hidden" id="hiddenbox">
<script>
function setavalue() {
if (event.srcElement.tagName=="A") {
document.getElementById('hiddenbox').value=event.srcElement.innerText}
}
</script>
</body>
</html>
Though this may not work in other browsers then IE as I have not used e ...
thanks for your reply
in my jsp page there exist hyper links from "A" to "Z" and when ever i click on any one of the letter once again it calls itself with a parameter as that clicked character.while loading i get the value which is passed through hidden field and executes a sql command and the result is plcaed below those hyper links.
regards
Inefficient (you only need to handle clicks on <a> elements, not any element), and yes, IE-only. You'd want to do something like this:<html>
<body onclick="setavalue()">
<a href="#">OK</a>
<a href="#">What</a>
<input type="hidden" id="hiddenbox">
<script>
function setavalue() {
if (event.srcElement.tagName=="A") {
document.getElementById('hiddenbox').value=event.srcElement.innerText}
}
</script>
</body>
</html>Code:<script type="text/javascript"> onload = function() { var f = function() { document.getElementById("hiddenbox").value = this.text; }; for(var i = 0, a = document.links; i < a.length; ++i) a[i].onclick = f; }; </script>
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Input fields don't have an "innerText" property anyways. They're tags which don't need to be closed.
Calling that from an anchor... does an anchor even have a "text" property?document.getElementById("hiddenbox").value = this.text;
- Mike
Indeed.Calling that from an anchor... does an anchor even have a "text" property?
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Bookmarks