Connecting Tech Pros Worldwide Help | Site Map

Javascript value in IE not being passed on

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 18th, 2006, 04:55 PM
frank78@gmail.com
Guest
 
Posts: n/a
Default Javascript value in IE not being passed on

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, 05:15 PM
VK
Guest
 
Posts: n/a
Default 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, 05:35 PM
mick white
Guest
 
Posts: n/a
Default 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, 07:15 PM
Frank Chen
Guest
 
Posts: n/a
Default 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, 08:35 PM
ASM
Guest
 
Posts: n/a
Default 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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.