Jump to content

simple js confusion


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
https://forums.phpfreaks.com/topic/276323-simple-js-confusion/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.