Passing document.form. value to another page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dkate777
    New Member
    • Jun 2007
    • 18

    Passing document.form. value to another page

    Hi,

    Is anybody know how to pass textbox input value to another page.

    I am using
    document.second form.fieldname. value=document. firstformname.f ieldname.value

    but it's not working

    Thanks
  • Purple
    Recognized Expert Contributor
    • May 2007
    • 404

    #2
    Hi,

    the approach you are following looks right (prob not what you wanted to hear), can you post the actual code and the html used to drive the javascript so we can take a look and help you better..

    Purple

    Comment

    • epots9
      Recognized Expert Top Contributor
      • May 2007
      • 1352

      #3
      Originally posted by dkate777
      Hi,

      Is anybody know how to pass textbox input value to another page.

      I am using
      document.second form.fieldname. value=document. firstformname.f ieldname.value

      but it's not working

      Thanks
      You need some server-side scripting, javascript and HTML are client side.

      when u create a form in HTML, the values are passed to another page.
      [HTML]<form method="GET" action="page.ph p"></form>[/HTML]

      method means how to send the data, GET u will see everything the address bar (mysite.com/page.php?someth ing=value&more= somethingelse) and POST wouldn't show up in the address bar (good for when u don't want passwords to be seen).
      action means the page that it goes to.

      the in the page.php
      [PHP]
      $val = $_GET["textboxnam e"];
      $val = $_POST["textboxnam e"];
      [/PHP]
      are used depending on what method u used in the form.

      Comment

      • dkate777
        New Member
        • Jun 2007
        • 18

        #4
        this is my code sampel

        I call second form from this line :

        <input type='button' align='right' value='Add New Test Requirement' class='fancyBut ton' style='width:20 0px' onClick='update Project("contro l")'>




        <div id='controlTabl e' style='position :absolute;
        overflow:auto;
        top:10px;
        left:245px;
        width:<?php echo $divWidth; ?>;
        height:680px;
        z-index:3;
        visibility="hid den"'>

        <form name='controlFo rm' method='post' onSubmit='retur n validateField(" control");'>
        <input type='hidden' name='userNumbe r' value='<?php echo $POST_userNumbe r; ?>'>
        <input type='hidden' name='projectNu mber' value='<?php echo $_SESSION[projectNumber]; ?>'>
        <table class='greyBar' width='100%' cellpadding='5' >
        <?php
        echo "
        <tr>
        <th colspan='4'><fo nt align='center' color='navy'>
        <h3>
        Software Change Control Form for Project #</font><font color='maroon'> $_SESSION[projectNumber]
        </h3>
        </font>
        </th>
        </tr> ";

        ?>
        <?php

        $testQuery="SEL ECT *
        FROM project_control test
        WHERE projectNumber=' $POST_projectNu mber'";
        $result=mysql_q uery($testQuery );
        $controlFound=f alse;
        $controlNumber= 0;
        while ($testrow = mysql_fetch_arr ay($result)) {
        $controlFound=t rue;
        } $controlNumber= $controlNumber+ 1;


        $controlQuery=" SELECT *
        FROM project_control
        WHERE projectUser=$_S ESSION[userNumber]
        and projectNumber=' $POST_projectNu mber'";
        $controlResult= mysql_query($co ntrolQuery);
        //$projectNumberF ound=false;
        $_SESSION['projectNumberF ound']=false;
        while ($row=mysql_fet ch_array($contr olResult)){
        // $projectNumberF ound=true;
        $_SESSION['projectNumberF ound']=true;
        $CurrentProject Number =$row[projectNumber];
        $CurrentProject User=$row[projectUser];
        $CurrentProject Description=$ro w[softwareDescrip tion];
        $SummaryofChang es=$row[SummaryofChange s];
        $Release=$row[currentreleaseL evel];
        $newRelease=$ro w[newreleaseLevel];
        $SchliveDate="" .convert_date($ row[ScheduledLiveDa te],'fromSQL')."";
        $ActualliveDate ="".convert_dat e($row[ActualLiveDate],'fromSQL')."";
        //$SymTestUser=ge t_user_info($ro w[SymTestUser],'name');
        //$SoftTestUser=g et_user_info($r ow[SoftTestUser],'name');
        //$ITAppUser=get_ user_info($row[ITAppUser],'name');
        //$OwnerUser=get_ user_info($row[OwnerUser],'name');
        //$SecurityUser=g et_user_info($r ow[SecurityUser],'name');
        }

        echo("<!--\$projectNumber Found=$projectN umberFound-->");



        ?>
        <tr>
        <td align='right' class='tdnavy'>
        Software Description:
        </td>
        <td>
        <input type='text'
        size='25'
        name='softdescr iption'
        value='<?php if ($_SESSION[projectNumberFo und]==true) {
        echo $CurrentProject Description;
        }else
        echo $_SESSION[softdescription];
        ?>'
        maxlength='50'> </input>
        </td>
        </tr>
        <tr>
        <td align='right' class='tdnavy'>
        Current Release/Build Level:
        </td>
        <td>
        <input type='text'
        size='25'
        name='release'
        value='<?php echo $Release ?>'
        maxlength='50'> </input>
        </td>
        </tr>
        <tr>
        <td align='right' class='tdnavy'>
        New Release/Build Level:
        </td>
        <td>
        <input type='text'
        size='25'
        name='newreleas e'
        value='<?php echo $newRelease ?>'
        maxlength='50'> </input>
        </td>
        </tr>
        <tr>
        <td align='right' class='tdnavy'>
        Requested Live Date:
        </td>
        <td class='tdnavy'>
        <input name='SchliveDa te'
        type='text'
        size='15'
        onBlur='chkDate Fld(this,"Schli veDate",true,tr ue)'
        value=''>
        <a href="javascrip t:showCal('Cale ndar14')">
        <img border='0' src='/images/b_calendar.png'
        alt='Get Date'>
        </a>&nbsp&nbsp Approved Live Date: &nbsp
        <input name='Actualliv eDate'
        type='text'
        size='15'
        onBlur='chkDate Fld(this,"Actua lliveDate",true ,true)'
        value=''>
        <a href="javascrip t:showCal('Cale ndar19')">
        <img border='0' src='/images/b_calendar.png'
        alt='Get Date'>
        </a>
        </td>
        </tr>

        <tr>
        <td align='right' class='tdnavy'>
        Summary of Changes:
        </td>
        <td>
        <?php echo "
        <textarea wrap=\"soft\"
        rows=\"3\"
        cols=\"80\"
        name=\"summaryd escription\">". $SummaryofChang es."</textarea>";

        ?>

        </td>
        </tr>
        <tr>
        <td >

        <?php

        <input type='button' align='right' value='Add New Test Requirement' class='fancyBut ton' style='width:20 0px' onClick='update Project("contro l")'>
        </td>
        </tr>

        <?php


        // if ($controlFound= =true){
        echo "
        <tr>
        <td colspan='3'>
        <form name='controlte st' method='post'>
        <div style='overflow :auto; height:100px;'>
        <table align='center' width='90%' border-style='inset' padding='0' bgcolor='#FOFOF O' >
        <tr>
        <th bgcolor='#FOFOF O' align='left'><f ont color='navy'>Fu nctionality to be Tested</font></th>
        <th bgcolor='#FOFOF O' align='left'><f ont color='navy'>Pe rson Responsible</font></th>
        <th bgcolor='#FOFOF O' align='left'><f ont color='navy'>Du e Date</font></th>
        <th bgcolor='#FOFOF O' align='left'><f ont color='navy'>Co mpletion Date</font></th>
        </tr>";

        $controlQuery=" SELECT *
        FROM project_control test
        WHERE projectNumber=' $POST_projectNu mber'";
        $result=mysql_q uery($controlQu ery);
        $controlFound=f alse;
        $controlNumber= 0;
        $count=mysql_nu m_rows($result) ;
        while ($controlrow = mysql_fetch_arr ay($result)) {
        $controlFound=t rue;
        $controlNumber= $controlNumber+ 1;
        // $projectNumber[]=$rows[$controlNumber];
        echo "
        <tr bgcolor='white' > " ;
        //<td>";
        echo "<tr input type='hidden' name='control' value='$control Number'> ";
        echo "<tr input type='hidden' name='projectNu mber[$controlNumber]'
        id='projectNumb er' value='$control row[projectNumber]'> ";


        echo "<td bgcolor='white' class='tdnavy' width='300px'>\ n";
        echo "<a onClick='update Project(\"testc ontrol\")' href='javascrip t:void(0)'>";
        echo "$controlro w[shortdescriptio n]</a> ";
        echo " </td>
        <td bgcolor='white' class='tdnavy' >"; echo get_user_info($ controlrow[personresponsib le],'name'); echo "</td>
        <td bgcolor='white' class='tdnavy'> ";echo convert_date($c ontrolrow[duedate],'fromSQL');
        echo "</td>
        <td bgcolor='white' class='tdnavy'> ";
        if (convert_date($ controlrow[completiondate],'fromSQL')<>'0 0/00/0000'){
        echo convert_date($c ontrolrow[completiondate],'fromSQL');
        }
        else echo '' ;
        echo "</td>";
        echo "</tr>";

        }

        echo "</table></div></form>";
        //}
        echo "<input type='hidden' name='maxcontro lNumber' value='$control Number'> ";
        echo "</tr>";

        // echo("<!--\$projectNumber =$projectNumber[]-->")
        ?>

        <!--<table class='greyBar' width='100%' cellpadding='5' >-->
        <!--<form name='controlFo rm' method='post' onSubmit='retur n validateField(" control");'>-->
        <tr>
        <td align='right' class='tdnavy'>
        Symital interface/integration tested: </td>
        <td class='tdnavy'> <input type='radio' name='symtest' value='yes' /> Yes
        <input type='radio' name='symtest' value='no' /> No </td>
        </tr>


        <tr>
        <td align='right' class='tdnavy'>
        Software tested on current test database: </td>
        <td class='tdnavy'> <input type='radio' name='softtest' value='yes' /> Yes
        <input type='radio' name='softtest' value='no' /> No </td>
        </tr>

        <tr>
        <td >
        <input type='button' value='Business Owner Approval' class='ApproveB utton' style='width:20 0px'>
        </td>
        </tr>
        <tr>
        <td>
        <input type='button' value='IT Approval' class='ApproveB utton' onClick='keepSe ttings()' style='width:20 0px'>
        </td>
        </tr>
        <tr>
        <td>
        <input type='button' value='Security Approval' class='ApproveB utton' onClick='keepSe ttings()' style='width:20 0px'>
        </td>
        </tr>
        </tr>

        <tr>
        <td align='center' colspan='2'>
        <input type='submit' value='<?php if ($projectNumber Found==true){
        echo "Update Request";}
        else
        echo "Create Request" ;?>'
        class='fancyBut ton' style='width:15 0px'>
        &nbsp
        <input type='button' value='Delete Request' class='fancyBut ton' onClick='keepSe ttings()' style='width:15 0px'>
        &nbsp
        <input type='button' value='Cancel' class='fancyBut ton' onClick='keepSe ttings()' style='width:15 0px'>
        </td>
        </tr>
        </table>
        </form>

        </div>

        /////////////////////////
        CHIALD FORM



        <div id='newcontrolT able' style='position :absolute;
        top:150px;
        left:150px;
        width:700px;
        height:400px;
        z-index:4;
        visibility="hid den"'>
        <form name='newcontro lForm' method='post' onSubmit='retur n validateField(" newcontrol")'>
        <input type='hidden' name='userNumbe r' value='<?php echo $POST_userNumbe r; ?>'>
        <input type='hidden' name='projectNu mber' value='<?php echo $POST_projectNu mber; ?>'>
        <input type='hidden' name='todayDate ' value=''>
        <input type='hidden' name='softdescr iption' value=''>
        <input type='hidden' name='summaryde scription' value=''>
        <input type='hidden' name='release' value=''>
        <input type='hidden' name='newreleas e' value=''>
        <input type='hidden' name='SchliveDa te' value=''>
        <input type='hidden' name='Actualliv eDate' value=''>
        <input type='hidden' name='projectNu mberFound' value=''>

        <input type='hidden' name='controlSt atus' value='restore' >
        <table class='projectB ar' align='right' width='100%' height='50%'>

        <script type='text/javascript'>

        document.newcon trolForm.todayD ate.text = document.contro lForm.todayDate .text
        document.newcon trolForm.softde scription.value = document.contro lForm.softdescr iption.value
        document.newcon trolForm.summar ydescription.va lue = document.contro lForm.summaryde scription.value
        document.newcon trolForm.releas e.value = document.contro lForm.release.v alue
        document.newcon trolForm.newrel ease.value = document.contro lForm.newreleas e.value
        document.newcon trolForm.Schliv eDate.value = document.contro lForm.SchliveDa te.value
        document.newcon trolForm.Actual liveDate.value = document.contro lForm.Actualliv eDate.value

        </script>


        <tr>
        <th colspan='2'>
        <h3>Add New Test Requirement</h3>
        </th>
        </tr>
        <tr>
        <th> Short Description:
        </th>
        <td>
        <input type='text'
        size='50'
        name='shortdesc ription'
        value=''
        maxlength='50'> </input>
        </td>

        </tr>
        <tr>
        <th>Functionali ty to be Tested:</th>
        <td>
        <textarea wrap='soft' rows='7' cols='70' name='funcText' value=''></textarea>
        </td>
        </tr>
        <tr>
        <td align='right'>
        Due Date:
        </td>
        <td >
        <input name='DueDate'
        type='text'
        size='15'
        onBlur='chkDate Fld(this,"DueDa te",true,true )'
        value=''>
        <a href="javascrip t:showCal('Cale ndar15')">
        <img border='0' src='/images/b_calendar.png'
        alt='Get Date'>
        </a>
        <tr>
        <td align='right' >
        Person Responsible:
        <span style='position :absolute;
        top: 150px;
        left: 20%;'>
        <select name='personres ponsible'
        size='7'
        style='display: none;'
        onClick=' javascript:this .style.display= "none";
        document.newcon trolForm.person responsibleInpu t.value=this.op tions[selectedIndex].text;'>
        <?php
        $userQuery="SEL ECT DISTINCT projectITRep
        FROM projects
        WHERE projectITRep<>0 ";
        $userResult=mys ql_query($userQ uery);
        echo " <option value=''";
        if ($_SESSION[personresponsib le]=='')
        echo " selected";
        echo ">Any";
        while ($userRow = mysql_fetch_arr ay($userResult) ){
        $ITApp[$userRow[projectITRep]]=get_user_info( $userRow[projectITRep],'name');
        }
        asort($ITApp);
        foreach($ITApp as $key=>$value){
        echo "<option value='$key'";
        if ($key== $_SESSION[personresponsib le]){
        echo " selected";
        }
        echo ">$value\n" ;
        }
        ?>
        </span>
        </td>
        <td class='tdnavy'>
        <input type='text'
        name='personres ponsibleInput'
        value='<?php if ($_SESSION[personresponsib le]<>'') echo get_user_info($ _SESSION[personresponsib le],'name');?>'
        size='25'
        onBlur= 'javascript:doc ument.newcontro lForm.personres ponsible.style. display="none"; '
        onClick='javasc ript:document.n ewcontrolForm.p ersonresponsibl e.style.display ="inline"'
        onKeyUp='javasc ript:obj11.bldU pdate(event,thi s);' >

        </td>
        </tr>
        </tr>

        <tr>
        <td></td>
        <td>
        <input type='submit' value='Submit' class='fancyBut ton'>
        <input type='button' value='Cancel' class='fancyBut ton' onClick='closeC ontrol("close") '>
        </td>
        </tr>
        </table>
        </form>
        </div>
        <!--End New Control Section-->

        Comment

        • dkate777
          New Member
          • Jun 2007
          • 18

          #5
          What i want to do, when i click on submit button from chiald page, and i should back to parents page with reload/refresh screen and parent form fields value should stay the same how i key them, but what ever i do, it's blank

          Comment

          • Purple
            Recognized Expert Contributor
            • May 2007
            • 404

            #6
            Hi,

            some questions -

            the following while loop has $controlNumber counter outside the loop - is that correct ?

            Code:
            while ($testrow = mysql_fetch_array($result)) 
            {
            $controlFound=true;
            } 
            $controlNumber=$controlNumber+1;
            the following code has two <?php statements - one of them needs terminating or removing

            [PHP]<?php

            <input type='button' align='right' value='Add New Test Requirement' class='fancyBut ton' style='width:20 0px' onClick='update Project("contro l")'>
            </td>
            </tr>

            <?php[/PHP]

            is this the problem - the html will be interpreted by the php processor - can you fix and run it cause I can't reproduce without the mysql db - also have you got errors turn on for php ?

            Purple
            Last edited by Purple; Jun 13 '07, 04:09 PM. Reason: cause it didnt format

            Comment

            • Purple
              Recognized Expert Contributor
              • May 2007
              • 404

              #7
              Hi,

              Also

              [PHP]<input type='hidden' name='userNumbe r' value='<?php echo $POST_userNumbe r; ?>'>
              <input type='hidden' name='projectNu mber' value='<?php echo $POST_projectNu mber; ?>'>[/PHP]

              could do with being as follows:

              [PHP]<input type='hidden' name='userNumbe r' value='<?php if (isset($POST['userNumber'])) echo $POST['userNumber']; else echo "";?>'>
              <input type='hidden' name='projectNu mber' value='<?php if (isset(echo $POST['projectNumber']; echo $POST['projectNumber']; else echo ""; ?>'>[/PHP]

              to prevent an error with undefined $_POST variables

              Purple

              Comment

              • dkate777
                New Member
                • Jun 2007
                • 18

                #8
                This form has another table with detail, so this ControlNumber calculation for this table, it's nothing to do with this form.
                THe second <php tag i just copy by mistake, it's not in real code

                Project number and userNumber is everywhere like this, I am not touch this part, because i just modified this huge application, someone did this way before and i don't want to mess with this and it's look like nothing to do with passing document form value

                Comment

                • Motoma
                  Recognized Expert Specialist
                  • Jan 2007
                  • 3236

                  #9
                  I tried catching up in this post, but I have become a little confused. Perhaps you could clarify for me what you are trying to do once more.

                  I understand you are trying to pass a value from one text field to another page, but are you doing it with a Javascript _parent child relationship or a form POST?

                  Comment

                  • dkate777
                    New Member
                    • Jun 2007
                    • 18

                    #10
                    i am doing this with Java script

                    <script type='text/javascript'>

                    document.newcon trolForm.todayD ate.text = document.contro lForm.todayDate .text
                    document.newcon trolForm.softde scription.value = document.contro lForm.softdescr iption.value
                    document.newcon trolForm.summar ydescription.va lue = document.contro lForm.summaryde scription.value
                    document.newcon trolForm.releas e.value = document.contro lForm.release.v alue
                    document.newcon trolForm.newrel ease.value = document.contro lForm.newreleas e.value
                    document.newcon trolForm.Schliv eDate.value = document.contro lForm.SchliveDa te.value
                    document.newcon trolForm.Actual liveDate.value = document.contro lForm.Actualliv eDate.value

                    </script>

                    POST it's not going to work for me. Because i have to fill parent form first, thant i have to click button on parents form and chiald form open.When i fill some information and submit data from chiald form shoul appear on parents form, but all parent field should stay the way how i key. The problem i have , that when i save and submit chiald screen and display information on parents screen, bouth screen reload and refresh, so the safe information from chiald screen there, but fields what was just key gone........... so i try to pass this fields that they stay there till i will submit information from parents screen.
                    Sorry, for complicated explonation, english it's not my primary language.

                    Comment

                    • Motoma
                      Recognized Expert Specialist
                      • Jan 2007
                      • 3236

                      #11
                      Originally posted by dkate777
                      i am doing this with Java script

                      <script type='text/javascript'>

                      document.newcon trolForm.todayD ate.text = document.contro lForm.todayDate .text
                      document.newcon trolForm.softde scription.value = document.contro lForm.softdescr iption.value
                      document.newcon trolForm.summar ydescription.va lue = document.contro lForm.summaryde scription.value
                      document.newcon trolForm.releas e.value = document.contro lForm.release.v alue
                      document.newcon trolForm.newrel ease.value = document.contro lForm.newreleas e.value
                      document.newcon trolForm.Schliv eDate.value = document.contro lForm.SchliveDa te.value
                      document.newcon trolForm.Actual liveDate.value = document.contro lForm.Actualliv eDate.value

                      </script>

                      POST it's not going to work for me. Because i have to fill parent form first, thant i have to click button on parents form and chiald form open.When i fill some information and submit data from chiald form shoul appear on parents form, but all parent field should stay the way how i key. The problem i have , that when i save and submit chiald screen and display information on parents screen, bouth screen reload and refresh, so the safe information from chiald screen there, but fields what was just key gone........... so i try to pass this fields that they stay there till i will submit information from parents screen.
                      Sorry, for complicated explonation, english it's not my primary language.

                      From what you have posted here, it seems like this is more of a Javascript related problem. I am going to forward this thread to the Javascript Forum with the hopes that the experts there will be able to give more insight into its solution.

                      Comment

                      • acoder
                        Recognized Expert MVP
                        • Nov 2006
                        • 16032

                        #12
                        Originally posted by dkate777
                        i am doing this with Java script

                        <script type='text/javascript'>

                        document.newcon trolForm.todayD ate.text = document.contro lForm.todayDate .text
                        document.newcon trolForm.softde scription.value = document.contro lForm.softdescr iption.value
                        document.newcon trolForm.summar ydescription.va lue = document.contro lForm.summaryde scription.value
                        document.newcon trolForm.releas e.value = document.contro lForm.release.v alue
                        document.newcon trolForm.newrel ease.value = document.contro lForm.newreleas e.value
                        document.newcon trolForm.Schliv eDate.value = document.contro lForm.SchliveDa te.value
                        document.newcon trolForm.Actual liveDate.value = document.contro lForm.Actualliv eDate.value

                        </script>

                        POST it's not going to work for me. Because i have to fill parent form first, thant i have to click button on parents form and chiald form open.When i fill some information and submit data from chiald form shoul appear on parents form, but all parent field should stay the way how i key. The problem i have , that when i save and submit chiald screen and display information on parents screen, bouth screen reload and refresh, so the safe information from chiald screen there, but fields what was just key gone........... so i try to pass this fields that they stay there till i will submit information from parents screen.
                        Sorry, for complicated explonation, english it's not my primary language.
                        Use window.opener to access the parent window, so, e.g.
                        [CODE=javascript]window.opener.d ocument.newcont rolForm.Actuall iveDate.value = document.contro lForm.Actualliv eDate.value[/CODE]

                        Comment

                        Working...