By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,480 Members | 1,224 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,480 IT Pros & Developers. It's quick & easy.

Passing document.form. value to another page

P: 18
Hi,

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

I am using
document.secondform.fieldname.value=document.first formname.fieldname.value

but it's not working

Thanks
Jun 13 '07 #1
Share this Question
Share on Google+
11 Replies


Purple
Expert 100+
P: 404
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
Jun 13 '07 #2

epots9
Expert 100+
P: 1,351
Hi,

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

I am using
document.secondform.fieldname.value=document.first formname.fieldname.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.php"></form>[/HTML]

method means how to send the data, GET u will see everything the address bar (mysite.com/page.php?something=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["textboxname"];
$val = $_POST["textboxname"];
[/PHP]
are used depending on what method u used in the form.
Jun 13 '07 #3

P: 18
this is my code sampel

I call second form from this line :

<input type='button' align='right' value='Add New Test Requirement' class='fancyButton' style='width:200px' onClick='updateProject("control")'>




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

<form name='controlForm' method='post' onSubmit='return validateField("control");'>
<input type='hidden' name='userNumber' value='<?php echo $POST_userNumber; ?>'>
<input type='hidden' name='projectNumber' value='<?php echo $_SESSION[projectNumber]; ?>'>
<table class='greyBar' width='100%' cellpadding='5'>
<?php
echo "
<tr>
<th colspan='4'><font align='center' color='navy'>
<h3>
Software Change Control Form for Project #</font><font color='maroon'> $_SESSION[projectNumber]
</h3>
</font>
</th>
</tr> ";

?>
<?php

$testQuery="SELECT *
FROM project_controltest
WHERE projectNumber='$POST_projectNumber'";
$result=mysql_query($testQuery);
$controlFound=false;
$controlNumber=0;
while ($testrow = mysql_fetch_array($result)) {
$controlFound=true;
} $controlNumber=$controlNumber+1;


$controlQuery="SELECT *
FROM project_control
WHERE projectUser=$_SESSION[userNumber]
and projectNumber='$POST_projectNumber'";
$controlResult=mysql_query($controlQuery);
//$projectNumberFound=false;
$_SESSION['projectNumberFound']=false;
while ($row=mysql_fetch_array($controlResult)){
// $projectNumberFound=true;
$_SESSION['projectNumberFound']=true;
$CurrentProjectNumber =$row[projectNumber];
$CurrentProjectUser=$row[projectUser];
$CurrentProjectDescription=$row[softwareDescription];
$SummaryofChanges=$row[SummaryofChanges];
$Release=$row[currentreleaseLevel];
$newRelease=$row[newreleaseLevel];
$SchliveDate="".convert_date($row[ScheduledLiveDate],'fromSQL')."";
$ActualliveDate="".convert_date($row[ActualLiveDate],'fromSQL')."";
//$SymTestUser=get_user_info($row[SymTestUser],'name');
//$SoftTestUser=get_user_info($row[SoftTestUser],'name');
//$ITAppUser=get_user_info($row[ITAppUser],'name');
//$OwnerUser=get_user_info($row[OwnerUser],'name');
//$SecurityUser=get_user_info($row[SecurityUser],'name');
}

echo("<!--\$projectNumberFound=$projectNumberFound-->");



?>
<tr>
<td align='right' class='tdnavy'>
Software Description:
</td>
<td>
<input type='text'
size='25'
name='softdescription'
value='<?php if ($_SESSION[projectNumberFound]==true) {
echo $CurrentProjectDescription;
}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='newrelease'
value='<?php echo $newRelease ?>'
maxlength='50'></input>
</td>
</tr>
<tr>
<td align='right' class='tdnavy'>
Requested Live Date:
</td>
<td class='tdnavy'>
<input name='SchliveDate'
type='text'
size='15'
onBlur='chkDateFld(this,"SchliveDate",true,true)'
value=''>
<a href="javascript:showCal('Calendar14')">
<img border='0' src='/images/b_calendar.png'
alt='Get Date'>
</a>&nbsp&nbsp Approved Live Date: &nbsp
<input name='ActualliveDate'
type='text'
size='15'
onBlur='chkDateFld(this,"ActualliveDate",true,true )'
value=''>
<a href="javascript:showCal('Calendar19')">
<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=\"summarydescription\">".$SummaryofChanges."</textarea>";

?>

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

<?php

<input type='button' align='right' value='Add New Test Requirement' class='fancyButton' style='width:200px' onClick='updateProject("control")'>
</td>
</tr>

<?php


// if ($controlFound==true){
echo "
<tr>
<td colspan='3'>
<form name='controltest' method='post'>
<div style='overflow:auto; height:100px;'>
<table align='center' width='90%' border-style='inset' padding='0' bgcolor='#FOFOFO' >
<tr>
<th bgcolor='#FOFOFO' align='left'><font color='navy'>Functionality to be Tested</font></th>
<th bgcolor='#FOFOFO' align='left'><font color='navy'>Person Responsible</font></th>
<th bgcolor='#FOFOFO' align='left'><font color='navy'>Due Date</font></th>
<th bgcolor='#FOFOFO' align='left'><font color='navy'>Completion Date</font></th>
</tr>";

$controlQuery="SELECT *
FROM project_controltest
WHERE projectNumber='$POST_projectNumber'";
$result=mysql_query($controlQuery);
$controlFound=false;
$controlNumber=0;
$count=mysql_num_rows($result);
while ($controlrow = mysql_fetch_array($result)) {
$controlFound=true;
$controlNumber=$controlNumber+1;
// $projectNumber[]=$rows[$controlNumber];
echo "
<tr bgcolor='white'> " ;
//<td>";
echo "<tr input type='hidden' name='control' value='$controlNumber'> ";
echo "<tr input type='hidden' name='projectNumber[$controlNumber]'
id='projectNumber' value='$controlrow[projectNumber]'> ";


echo "<td bgcolor='white' class='tdnavy' width='300px'>\n";
echo "<a onClick='updateProject(\"testcontrol\")' href='javascript:void(0)'>";
echo "$controlrow[shortdescription]</a> ";
echo " </td>
<td bgcolor='white' class='tdnavy' >"; echo get_user_info($controlrow[personresponsible],'name'); echo "</td>
<td bgcolor='white' class='tdnavy'>";echo convert_date($controlrow[duedate],'fromSQL');
echo "</td>
<td bgcolor='white' class='tdnavy'>";
if (convert_date($controlrow[completiondate],'fromSQL')<>'00/00/0000'){
echo convert_date($controlrow[completiondate],'fromSQL');
}
else echo '' ;
echo "</td>";
echo "</tr>";

}

echo "</table></div></form>";
//}
echo "<input type='hidden' name='maxcontrolNumber' value='$controlNumber'> ";
echo "</tr>";

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

<!--<table class='greyBar' width='100%' cellpadding='5'>-->
<!--<form name='controlForm' method='post' onSubmit='return 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='ApproveButton' style='width:200px'>
</td>
</tr>
<tr>
<td>
<input type='button' value='IT Approval' class='ApproveButton' onClick='keepSettings()' style='width:200px'>
</td>
</tr>
<tr>
<td>
<input type='button' value='Security Approval' class='ApproveButton' onClick='keepSettings()' style='width:200px'>
</td>
</tr>
</tr>

<tr>
<td align='center' colspan='2'>
<input type='submit' value='<?php if ($projectNumberFound==true){
echo "Update Request";}
else
echo "Create Request" ;?>'
class='fancyButton' style='width:150px'>
&nbsp
<input type='button' value='Delete Request' class='fancyButton' onClick='keepSettings()' style='width:150px'>
&nbsp
<input type='button' value='Cancel' class='fancyButton' onClick='keepSettings()' style='width:150px'>
</td>
</tr>
</table>
</form>

</div>

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



<div id='newcontrolTable' style='position:absolute;
top:150px;
left:150px;
width:700px;
height:400px;
z-index:4;
visibility="hidden"'>
<form name='newcontrolForm' method='post' onSubmit='return validateField("newcontrol")'>
<input type='hidden' name='userNumber' value='<?php echo $POST_userNumber; ?>'>
<input type='hidden' name='projectNumber' value='<?php echo $POST_projectNumber; ?>'>
<input type='hidden' name='todayDate' value=''>
<input type='hidden' name='softdescription' value=''>
<input type='hidden' name='summarydescription' value=''>
<input type='hidden' name='release' value=''>
<input type='hidden' name='newrelease' value=''>
<input type='hidden' name='SchliveDate' value=''>
<input type='hidden' name='ActualliveDate' value=''>
<input type='hidden' name='projectNumberFound' value=''>

<input type='hidden' name='controlStatus' value='restore'>
<table class='projectBar' align='right' width='100%' height='50%'>

<script type='text/javascript'>

document.newcontrolForm.todayDate.text = document.controlForm.todayDate.text
document.newcontrolForm.softdescription.value = document.controlForm.softdescription.value
document.newcontrolForm.summarydescription.value = document.controlForm.summarydescription.value
document.newcontrolForm.release.value = document.controlForm.release.value
document.newcontrolForm.newrelease.value = document.controlForm.newrelease.value
document.newcontrolForm.SchliveDate.value = document.controlForm.SchliveDate.value
document.newcontrolForm.ActualliveDate.value = document.controlForm.ActualliveDate.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='shortdescription'
value=''
maxlength='50'></input>
</td>

</tr>
<tr>
<th>Functionality 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='chkDateFld(this,"DueDate",true,true)'
value=''>
<a href="javascript:showCal('Calendar15')">
<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='personresponsible'
size='7'
style='display:none;'
onClick=' javascript:this.style.display="none";
document.newcontrolForm.personresponsibleInput.val ue=this.options[selectedIndex].text;'>
<?php
$userQuery="SELECT DISTINCT projectITRep
FROM projects
WHERE projectITRep<>0";
$userResult=mysql_query($userQuery);
echo " <option value=''";
if ($_SESSION[personresponsible]=='')
echo " selected";
echo ">Any";
while ($userRow = mysql_fetch_array($userResult)){
$ITApp[$userRow[projectITRep]]=get_user_info($userRow[projectITRep],'name');
}
asort($ITApp);
foreach($ITApp as $key=>$value){
echo "<option value='$key'";
if ($key== $_SESSION[personresponsible]){
echo " selected";
}
echo ">$value\n";
}
?>
</span>
</td>
<td class='tdnavy'>
<input type='text'
name='personresponsibleInput'
value='<?php if ($_SESSION[personresponsible]<>'') echo get_user_info($_SESSION[personresponsible],'name');?>'
size='25'
onBlur= 'javascript:document.newcontrolForm.personresponsi ble.style.display="none";'
onClick='javascript:document.newcontrolForm.person responsible.style.display="inline"'
onKeyUp='javascript:obj11.bldUpdate(event,this);' >

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

<tr>
<td></td>
<td>
<input type='submit' value='Submit' class='fancyButton'>
<input type='button' value='Cancel' class='fancyButton' onClick='closeControl("close")'>
</td>
</tr>
</table>
</form>
</div>
<!--End New Control Section-->
Jun 13 '07 #4

P: 18
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
Jun 13 '07 #5

Purple
Expert 100+
P: 404
Hi,

some questions -

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

Expand|Select|Wrap|Line Numbers
  1. while ($testrow = mysql_fetch_array($result)) 
  2. {
  3. $controlFound=true;
  4. $controlNumber=$controlNumber+1;
  5.  
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='fancyButton' style='width:200px' onClick='updateProject("control")'>
</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
Jun 13 '07 #6

Purple
Expert 100+
P: 404
Hi,

Also

[PHP]<input type='hidden' name='userNumber' value='<?php echo $POST_userNumber; ?>'>
<input type='hidden' name='projectNumber' value='<?php echo $POST_projectNumber; ?>'>[/PHP]

could do with being as follows:

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

to prevent an error with undefined $_POST variables

Purple
Jun 13 '07 #7

P: 18
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
Jun 13 '07 #8

Motoma
Expert 2.5K+
P: 3,237
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?
Jun 13 '07 #9

P: 18
i am doing this with Java script

<script type='text/javascript'>

document.newcontrolForm.todayDate.text = document.controlForm.todayDate.text
document.newcontrolForm.softdescription.value = document.controlForm.softdescription.value
document.newcontrolForm.summarydescription.value = document.controlForm.summarydescription.value
document.newcontrolForm.release.value = document.controlForm.release.value
document.newcontrolForm.newrelease.value = document.controlForm.newrelease.value
document.newcontrolForm.SchliveDate.value = document.controlForm.SchliveDate.value
document.newcontrolForm.ActualliveDate.value = document.controlForm.ActualliveDate.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.
Jun 13 '07 #10

Motoma
Expert 2.5K+
P: 3,237
i am doing this with Java script

<script type='text/javascript'>

document.newcontrolForm.todayDate.text = document.controlForm.todayDate.text
document.newcontrolForm.softdescription.value = document.controlForm.softdescription.value
document.newcontrolForm.summarydescription.value = document.controlForm.summarydescription.value
document.newcontrolForm.release.value = document.controlForm.release.value
document.newcontrolForm.newrelease.value = document.controlForm.newrelease.value
document.newcontrolForm.SchliveDate.value = document.controlForm.SchliveDate.value
document.newcontrolForm.ActualliveDate.value = document.controlForm.ActualliveDate.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.
Jun 13 '07 #11

acoder
Expert Mod 15k+
P: 16,027
i am doing this with Java script

<script type='text/javascript'>

document.newcontrolForm.todayDate.text = document.controlForm.todayDate.text
document.newcontrolForm.softdescription.value = document.controlForm.softdescription.value
document.newcontrolForm.summarydescription.value = document.controlForm.summarydescription.value
document.newcontrolForm.release.value = document.controlForm.release.value
document.newcontrolForm.newrelease.value = document.controlForm.newrelease.value
document.newcontrolForm.SchliveDate.value = document.controlForm.SchliveDate.value
document.newcontrolForm.ActualliveDate.value = document.controlForm.ActualliveDate.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.
Expand|Select|Wrap|Line Numbers
  1. window.opener.document.newcontrolForm.ActualliveDate.value = document.controlForm.ActualliveDate.value
Jun 14 '07 #12

Post your reply

Sign in to post your reply or Sign up for a free account.