Javascript value in IE not being passed on

Discussion in 'Javascript' started by frank78@gmail.com, Nov 18, 2006.

  1. Guest

    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
     
    , Nov 18, 2006
    #1
    1. Advertising

  2. VK Guest

    wrote:
    > 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.
     
    VK, Nov 18, 2006
    #2
    1. Advertising

  3. mick white Guest

    wrote:
    > 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 white, Nov 18, 2006
    #3
  4. Frank Chen Guest

    mick white wrote:
    > wrote:
    > > 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
     
    Frank Chen, Nov 18, 2006
    #4
  5. ASM Guest

    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>



    --
    Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    Stephane Moriaux and his (less) old Mac already out of date
     
    ASM, Nov 18, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dee
    Replies:
    9
    Views:
    525
    Joseph Byrns
    Apr 15, 2005
  2. Anand
    Replies:
    2
    Views:
    915
    Anand
    Sep 11, 2003
  3. DC
    Replies:
    0
    Views:
    322
  4. Lilith
    Replies:
    10
    Views:
    500
    peter koch
    Dec 20, 2007
  5. Rahul
    Replies:
    2
    Views:
    365
    Richard Heathfield
    Feb 5, 2008
Loading...

Share This Page