Connecting Tech Pros Worldwide Help | Site Map

Javascript value in IE not being passed on

  #1  
Old November 18th, 2006, 05:55 PM
frank78@gmail.com
Guest
 
Posts: n/a
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

  #2  
Old November 18th, 2006, 06:15 PM
VK
Guest
 
Posts: n/a

re: Javascript value in IE not being passed on



frank78@gmail.com wrote:
Quote:
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.

  #3  
Old November 18th, 2006, 06:35 PM
mick white
Guest
 
Posts: n/a

re: Javascript value in IE not being passed on


frank78@gmail.com wrote:
Quote:
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
  #4  
Old November 18th, 2006, 08:15 PM
Frank Chen
Guest
 
Posts: n/a

re: Javascript value in IE not being passed on



mick white wrote:
Quote:
frank78@gmail.com wrote:
Quote:
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
Quote:
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

  #5  
Old November 18th, 2006, 09:35 PM
ASM
Guest
 
Posts: n/a

re: Javascript value in IE not being passed on


Frank Chen a écrit :
Quote:
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[i].type=="text")
f['assign_to'].value += escape(f[i].name+'='+f[i].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>



--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Perferred way to embed javascript into xhtml howa answers 4 April 15th, 2007 10:45 PM
Form not passing data ??? Noozer answers 10 July 25th, 2005 07:45 AM
Output VALUE of INPUT textfield using document.write Stumped and Confused answers 13 July 23rd, 2005 02:54 PM
Probelm with cfoutput / document.write JS function in Netscape 7 Yvan J. Gagnon answers 4 July 20th, 2005 09:58 AM