Javascript value in IE not being passed on

F

frank78

Hi all,

I'm having an issue with passing form values from one page to the next.
I wrote a function that I use to change the value of a hidden field to
any number of dynamically generated form select value.

The function "works" in the sense that when I alert, the same values
occur. This tells me some value is being set to the id = form_name
input field. however, this information is not being "POSTED" when I
submit the form.

Firefox has no issues. It will alert the same values AND post the
correct values to the next page.

<script type="text/javascript" language="JavaScript">
function changeAssignedTo(form_name) {
document.getElementById("assign_to").value =
document.getElementById(form_name).value;
alert(document.getElementById(form_name).value);
alert(document.getElementById("assign_to").value);
//alert(document.getElementById("assign_to").value );
}
</script>

Could anyone help me debug this? I have also tried the following
statements to no avail. (They may be malformed)
document.getElementById("assign_to").value =
document.getElementById(form_name).value;
document.assignment_form.assign_to.value =
document.getElementById(form_name).value;
window.document.assignment_form.assign_to.value =
document.getElementById(form_name).value;

Thanks much,
Frank
 
V

VK

I'm having an issue with passing form values from one page to the next.
I wrote a function that I use to change the value of a hidden field to
any number of dynamically generated form select value.

The function "works" in the sense that when I alert, the same values
occur. This tells me some value is being set to the id = form_name
input field. however, this information is not being "POSTED" when I
submit the form.

Only elements with "name" attribute set are being submitted. If Firefox
submits elements without "name" attribute set then it is a rather
serious misbehavior to investigate. What version of Firefox are you
using?

Ensure that all involved elements you have to submit to the server are
having name attribute set.
 
M

mick white

Hi all,

I'm having an issue with passing form values from one page to the next.
I wrote a function that I use to change the value of a hidden field to
any number of dynamically generated form select value.

The function "works" in the sense that when I alert, the same values
occur. This tells me some value is being set to the id = form_name
input field. however, this information is not being "POSTED" when I
submit the form.

Firefox has no issues. It will alert the same values AND post the
correct values to the next page.

<script type="text/javascript" language="JavaScript">
function changeAssignedTo(form_name) {
document.getElementById("assign_to").value =
document.getElementById(form_name).value;
alert(document.getElementById(form_name).value);
alert(document.getElementById("assign_to").value);
//alert(document.getElementById("assign_to").value );
}
</script>

Could anyone help me debug this? I have also tried the following
statements to no avail. (They may be malformed)
document.getElementById("assign_to").value =
document.getElementById(form_name).value;
document.assignment_form.assign_to.value =
document.getElementById(form_name).value;
window.document.assignment_form.assign_to.value =
document.getElementById(form_name).value;

Thanks much,
Frank
I assume your form controls are "named"

<script type="text/javascript" >
function changeAssignedTo(form_name){
var d=document.forms[0];
d.elements["assign_to"].value=
d.elements[form_name][d.elements[form_name].selectedIndex].value
} </script>

Something like that

Mick
 
F

Frank Chen

mick said:
Hi all,

I'm having an issue with passing form values from one page to the next.
I wrote a function that I use to change the value of a hidden field to
any number of dynamically generated form select value.

The function "works" in the sense that when I alert, the same values
occur. This tells me some value is being set to the id = form_name
input field. however, this information is not being "POSTED" when I
submit the form.

Firefox has no issues. It will alert the same values AND post the
correct values to the next page.

<script type="text/javascript" language="JavaScript">
function changeAssignedTo(form_name) {
document.getElementById("assign_to").value =
document.getElementById(form_name).value;
alert(document.getElementById(form_name).value);
alert(document.getElementById("assign_to").value);
//alert(document.getElementById("assign_to").value );
}
</script>

Could anyone help me debug this? I have also tried the following
statements to no avail. (They may be malformed)
document.getElementById("assign_to").value =
document.getElementById(form_name).value;
document.assignment_form.assign_to.value =
document.getElementById(form_name).value;
window.document.assignment_form.assign_to.value =
document.getElementById(form_name).value;

Thanks much,
Frank
I assume your form controls are "named"

<script type="text/javascript" >
function changeAssignedTo(form_name){
var d=document.forms[0];
d.elements["assign_to"].value=
d.elements[form_name][d.elements[form_name].selectedIndex].value
} </script>

Something like that

Mick

Mick, I tried your solution.

The code for my input box is as follows: <input type="text"
name="assign_to" id="assign_to" value="">

However, even when I change the value manually for example, to
var d=document.forms[0];
d.elements["assign_to"].value='38'

I try to use this post variable in my php page and nothing is set
inside the variable.

Thanks for the help.
Frank
 
A

ASM

Frank Chen a écrit :
I try to use this post variable in my php page and nothing is set
inside the variable.

With method get (didn't try in php + post)
examples bellow works fine with my browsers

<script type="text/javascript">
function $(id) { return document.getElementById(id); }
function changeAssignedTo(form_name) {
$("assign_to").value = $(form_name).value;
}
</script>
<form action="test.htm" method="get" onsubmit="changeAssignedTo('I_1');">
<input type="text" name="I_1" id="I_1" />
<input type="text" name="I_2" id="I_2" />
<input type="submit" value="GO" />
<input type="hidden" name="assign_to" id="assign_to" />
</form>

or

<script type="text/javascript">
function verif() {
var f = document.forms[0];
for(var i=0; i<f.length; i++)
if(f.type=="text")
f['assign_to'].value += escape(f.name+'='+f.value+'|');
// alert(f.assign_to.value);
return true;
}
</script>
<form action="test.htm" method="get" onsubmit="return verif();">
<input type="text" name="I_1" />
<input type="text" name="I_2" />
<input type="text" name="I_3" />
<input type="submit" value="GO" />
<input type="hidden" name="assign_to" />
</form>
 

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

No members online now.

Forum statistics

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

Latest Threads

Top