Re: Referencing a dynamically generated control name in JS
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Brian_Tsang
Posted On:   Saturday, May 20, 2006 04:09 AM

I have a form with fields that are composed from a ResultSet of a database fetch, and composing names for some hidden fields associated with the data set. I want to use a javascript to update the status (hidden field value) according to changes from an input field. How do I reference such a dynamically generated hidden field name? The error message complains that the field I passed in is null or not an object. e.g. function updateStatus ( fieldtag, flag ) { //Get the form name in the current generated html page var rec_details_form = document.forms["MarcRecDetails"]; rec_details_form.fieldtag.value = flag; //Test the modified value alert ( "Status of "    More>>

I have a form with fields that are composed from a ResultSet of a database fetch, and composing names for some hidden fields associated with the data set. I want to use a javascript to update the status (hidden field value) according to changes from an input field. How do I reference such a dynamically generated hidden field name? The error message complains that the field I passed in is null or not an object.


e.g.

			
function updateStatus ( fieldtag, flag ) {
//Get the form name in the current generated html page
var rec_details_form = document.forms["MarcRecDetails"];
rec_details_form.fieldtag.value = flag;

//Test the modified value
alert ( "Status of " + fieldtag + " : " + rec_details_form.row.value );
}


One row of the form code:
















-----------------------------------------



Not sure if all that makes sense. But I hope someone could shed some lights please.


Many thanks.

-Brian    <<Less

Re[2]: Referencing a dynamically generated control name in JS

Posted By:   Robert_Lybarger  
Posted On:   Saturday, May 20, 2006 07:32 AM

Your "onChange" event could also pass "this" in the argument chain, and you can then treat it generically in the JS function. (Assuming only the same sort of page object is calling that function, anyway.) Consider:


function updateStatus(fieldtag, flag, obj) {
...
alert("blah blah"+obj.value);
}

...



...
About | Sitemap | Contact