1,105,416 Community Members

assign the value to a hidden field

Member Avatar
surekhavk
Newbie Poster
10 posts since May 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

have a javascript
in which i am trying to assign the value to a hidden field and getting the below msg

'document.Form1.H_ROWID' is null or not an object

i am getting the value in the alert box but not able to assign it o teh control

alert("row " +M_ROWID)
document.Form1.H_ROWID.value = M_ROWID
Member Avatar
scrager
Newbie Poster
15 posts since Feb 2009
Reputation Points: 22 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

You'll need to post the HTML that goes along with this. My guess is that your form is not named, or the form has a miss-spelled input field.

Member Avatar
Krondorl
Newbie Poster
3 posts since Aug 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

You should actually be setting the hidden field like this: document.getElementById('H_ROWID').value=M_ROWID;

Member Avatar
essential
Posting Shark
974 posts since Aug 2008
Reputation Points: 84 [?]
Q&As Helped to Solve: 138 [?]
Skill Endorsements: 0 [?]
Featured
 
0
 

Hi,

under IE mode you must include a name="someName" attribute along with your input elements'. Here's a quick demontration:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title>http://www.daniweb.com</title>
<style type="text/css">
<!--

-->
</style>
<script type="text/javascript">
<!--
window.onload = function() {
var form;
   if ( document.all ) { form = form1; }
   else { form = document.getElementById("form1"); }
   form.H_ROWID.value = form.M_ROWID.value;
   alert( "row " + form.H_ROWID.value );
};
// --> 
</script>
</head>
<body>
<div>
<form id="form1" name="form1" action="#" onsubmit="return false;">
<div>
Test field: <input type="hidden" id="H_ROWID" name="H_ROWID" value="">
Test field<input type="text" id="M_ROWID" name="M_ROWID" value="Default Value">
</div>
</form>
</body>
</html>
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article