Hi aaronchan
It works on Opera... but does not work on Mozilla Firefox! Any idea?
Thanks
Srikanth
Main Topics
Browse All TopicsHi,
I have a form like this:
<form onsubmit="return formCheck(this);" method="POST">
<div name="name1">
<p>Author
<input name="input1" type="text"/>
</div>
<div name="name2">
<p>Editor
<input name="input2" type="text"/>
</div>
</form>
Now I need to write a code something like this:
var mytext=""
for (revfield in formobj.elements) {
var mynode = formobj.elements[revfield]
//process
}
I want to pick up every input element for this form and show an alert message with its value prefixed with its corresponding <p> value, i.e. like this:
If input1="John" and input2="Mark", then the alert should be "Author: John. Editor: Mark"
Is it possible? Kindly help
Thanks
Srikanth
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: aaronchanPosted on 2006-10-20 at 06:49:02ID: 17773627
Hope this helps:
ame('input '); Case() == 'text') { > 0) { ] = fNodeList[i].parentNode.in nerText.re place(/\s+ $/g, '') + ': ' + fNodeList[i].value;
<script>
function formCheck(form_elem) {
var fNodeList = document.getElementsByTagN
var outputStr = new Array();
for (var i = 0; i < fNodeList.length; i++) {
if (fNodeList[i].type.toLower
if (fNodeList[i].value.length
outputStr[outputStr.length
}
}
}
alert(outputStr.join('. '));
return false;
}
</script>
<form onsubmit="return formCheck(this);" method="POST">
<div name="name1">
<p />Author
<input name="input1" type="text"/>
</div>
<div name="name2">
<p />Editor
<input name="input2" type="text"/>
</div>
<br/>
<input type="submit" value="Submit" />
</form>