Jump to content

simple js confusion


ginerjm
Go to solution Solved by ginerjm,

Recommended Posts

I am trying to copy some input values from one form to another using the onclick event of my submit button.

 

The submit button in the "receiving" form looks like:

onclick="return copyChoice(this.form)"

and my function to do this looks like:

function copyChoice(frm)
{
	var evt_val='';
	var cb_plyr_sel_val ='';
	// inputs are 'evt' and 'cb_plyr_sel'
	if (document.getElementById('cb_plyr_sel').checked)
	{
	       	cb_plyr_sel_val = document.getElementById('cb_plyr_sel').value;
	}
	evt_val = document.getElementById("evt").value;
	// now copy the values to the hidden ones in this form
	???
        alert("values copyied?");
	return True;
}

My problem is in the ??? area where I am trying to place the two values I've captured into the frm object that I have from the submit button.  I have tried a couple of ways like this:

frm.evt = evt_val;  // where evt is the 'name' of the input in this form (frm)
AND:
var formid = frm.id;
document.getElementById(formid).evt = evt_val;







and neither of them worked.  I know this since my alert at the end never arrives.

 

So - given a form object, how do I reference the <input> tags within that form?  The examples I've found (and tried to use here) don't seem to be working for me.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.