Placing value in hidden input onsubmit

T

tks423

Hi,

On submitting the form, I'm trying to place the items of a listbox in
a hidden input. It doesn't work. Is my approach correct?

I have a form like this:

<form name="myForm" onsubmit="return listBoxContents(this.Form.sel1)"
action="project_selection.php" method="post">

and a function as below:

function listBoxContents(sel1)
{
var selLength1 = sel1.options.length,i,values1='';

for(i=0; i<selLength1; i++)
values1+=sel1.options.value+ ",";

document.myForm.hiddenName.value = values1;

return true;
}

and the hidden value is as follows:

<input type=hidden name="hiddenName" value="initial">
 
T

tks423

Hi,

On submitting the form, I'm trying to place the items of a listbox in
a hidden input. It doesn't work. Is my approach correct?

I have a form like this:

<form name="myForm" onsubmit="return listBoxContents(this.Form.sel1)"
action="project_selection.php" method="post">

and a function as below:

function listBoxContents(sel1)
{
var selLength1 = sel1.options.length,i,values1='';

for(i=0; i<selLength1; i++)
values1+=sel1.options.value+ ",";

document.myForm.hiddenName.value = values1;

return true;

}

and the hidden value is as follows:

<input type=hidden name="hiddenName" value="initial">



I found that this worked instead: <form name="myForm" onsubmit="return
listBoxContents(this.sel1)" action="project_selection.php"
method="post">
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top