Jump to content

[SOLVED] passing value


cleary1981

Recommended Posts

Hi I have two pages where I want to pass a value from one page to the next. I want to pass "proj_id_edit".Heres my first page.

 

<?php
if ($_COOKIE["auth"] == "1") {

} else {
//redirect back to login form if not authorised
header ("Location: loginform.html");
exit;
}

?>

<html>
<head>
<title>TES - Business Developement</title>
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="style.css" />
<style type="text/css">
</style>
<script language="javascript" src="list_companies.php"></script>
<script type="text/javascript" src="text-utils.js"> </script>
<script type="text/javascript" src="request.js"> </script>
<script type="text/javascript">
var p_id;
window.onload = function() {
fillCompany(); 
}
function get_Company() {
fillProject();
var comp = document.getElementById("Company").value;
var url = "lookupAccNo.php?comp=" + escape(comp);
request.open("GET", url, true);
request.onreadystatechange = updateAccNo;
request.send(null);
}
function updateAccNo() {
if (request.readyState ==4) {
	var accountnumber = request.responseText;
	var x = document.getElementById("acc_no");
	replaceText(x, accountnumber);
}
}
function get_project() {
var proj = document.getElementById("project").value;
var url = "lookupProjId.php?proj=" + escape(proj);
url = url + "&dummy=" + new Date().getTime();
request.open("GET", url, true);
request.onreadystatechange = updateProj;
request.send(null);
}
function updateProj() {
if (request.readyState == 4) {
var returned = request.responseText;
var splitResult = returned.split("%");
var r_proj_id = splitResult[0];
var r_projName = splitResult[1];
var r_form = splitResult[2];
var r_access = splitResult[3];
var r_cable = splitResult[4];
var r_ip = splitResult[5];
var r_fault = splitResult[6];
var r_comp = splitResult[7];
var r_pman = splitResult[8];
var r_deadline = splitResult[9];


document.company1.proj_id_edit.value = r_proj_id;
document.company1.projName_edit.value = r_projName;
document.company1.comp_edit.value = r_comp;
document.company1.access_edit.value = r_access;
document.company1.cable_edit.value = r_cable;
document.company1.ip_edit.value = r_ip;
document.company1.fault_edit.value = r_fault;
document.company1.iform_edit.value = r_form;
document.company1.pman_edit.value = r_pman;
document.company1.deadline_edit.value = r_deadline;
}
}




function updateProjectDetails() {
var uproj_id = document.getElementById("proj_id_edit").value;
var uaccess = document.getElementById("access_edit").value;
var ucable = document.getElementById("cable_edit").value;
var uip = document.getElementById("ip_edit").value;
var ufault = document.getElementById("fault_edit").value;
var uform = document.getElementById("iform_edit").value;
var upman = document.getElementById("pman_edit").value;
var udl = document.getElementById("deadline_edit").value;
var url = "updateProjectDetails.php?uproj_id=" + escape(uproj_id) + "&uaccess=" + escape(uaccess) + "&ucable=" + escape(ucable) + "&uip=" + escape(uip) + "&ufault=" + escape(ufault) + "&uform=" + escape(uform) + "&upman=" + escape(upman) + "&udl=" + escape(udl);
url = url + "&dummy=" + new Date().getTime();
request.open("GET", url, true);
request.onreadystatechange = showConfirmation;
request.send(null); 
}
function showConfirmation () {
	if (request.readyState == 4) {
	var xx = document.getElementById("xx");
	ss = document.createTextNode("Update complete"); 
	xx.appendChild(ss);
	var t=setTimeout("xx.removeChild(ss)",2000); //display message for 2seconds then removes it

}	
}
function openDesignMode() {
window.open('designmode.php', 'Design View', 'statusbar=yes');
}
</script>
</head>
<body>
<form name="company1" action="updateProjectDetails.php" method="POST">
<fieldset>
<legend>1. Select Company (or add company to database then press F5 to refresh list)</legend>
  		<table border=0 width=100%><tr><td width=45%><div><label for="Company" id="label1">Company Name</label>
		<SELECT id="Company" NAME="Company" onChange="get_Company()">
		<Option value="">Existing Company</option>
		</SELECT></div></td>
		<td width=45%><div><label for="acc_no" id="label2">Account Number</label>
		<span id="acc_no"> </span></div></td>
		<td><input type = "button" value = "newCompany" id="comp_button" onClick = "window.open('newcompany.php', 'NewCompany', 'width=400, height=400 statusbar=yes')">
		</td></tr></table>
		</fieldset>
<fieldset>
<legend>2. Select an existing project or create a new project</legend>
  		<table border=0 width=100%><tr><td width=45%><div><label for="project">Project Name</label>
		<SELECT id="project" NAME="project" onChange="get_project();">
		<Option value="">Existing Project</option>
		</SELECT></div></td>
		<td width=45%><div>
		<span id="proj_id1"> </span></div></td>
		<td><input type = "button" value = "New Project" onClick = "window.open('newproject.php', 'NewProject', 'width=400, height=400 statusbar=1, status=yes')">
		</td></tr></table>
		</fieldset>
<fieldset>
<legend>3. Update project details (if required)</legend>
<table width=100% border=0>
<tr>
<td><label for="proj_id_edit">Project ID</label>
<input type = "text" value = "" disabled name = "proj_id_edit" id = "proj_id_edit" onChange="setProject"></td>
<td><label for="projName_edit">Project Name</label>
<input type = "text" value = "" disabled name = "projName_edit" id = "projName_edit"></td></tr>
<tr><td><label for="comp_edit">Company Name</label>
<input type = "text" value = "" disabled name = "comp_edit" id = "comp_edit"></td>
<td><label for="access_edit">Access</label>
<input type = "text" value = "" name = "access_edit" id = "access_edit"></td></tr>
<tr><td><label for="cable_edit">Cable Entry</label>
<input type = "text" value = "" name = "cable_edit" id = "cable_edit"></td>
<td><label for="ip_edit">IP Rating</label>
<input type = "text" value = "" name = "ip_edit" id = "ip_edit"></td></tr>
<tr><td><label for="fault_edit">Fault Rating</label>
<input type = "text" value = "" name = "fault_edit" id = "fault_edit"><span>KW/sec</span></td>
<td><label for="iform_edit">Form</label>
<input type = "text" value = "" name = "iform_edit" id = "iform_edit"></td></tr>
<tr><td><label for="pman_edit">Project Manager</label>
<input type = "text" value = "" name = "pman_edit" id = "pman_edit"></td>
<td><label for="deadline_edit">Tender Deadline</label>
<input type = "text" value = "" name = "deadline_edit" id = "deadline_edit"></td>
</tr>
<tr><td><input type="button" value="Update" name="update" onClick="updateProjectDetails()">
<div id="xx"></div></td></tr></table>
</fieldset>
<fieldset>
<legend>4. Proceed to Design Mode</legend>
<input type="button" value="Design Mode" onClick = "window.open('designmode.php?p_id = {document.getElementById("proj_id_edit").value}', '', 'width=1280, height=700, resizable=yes, statusbar=yes')">
</fieldset>
</form>
</body>
</html>

 

Heres the second

<?php
if ($_COOKIE["auth"] == "1") {

} else {
//redirect back to login form if not authorised
header ("Location: loginform.html");
exit;
}


?>

 

Link to comment
Share on other sites

Use this

 

<?php

@extract($_POST);

 

echo $proj_id_edit; // your value for this variable will be printed here

 

if ($_COOKIE["auth"] == "1") {

 

} else {

//redirect back to login form if not authorised

header ("Location: loginform.html");

exit;

}

 

 

?>

Link to comment
Share on other sites

Hmm you are lost  :(

This is

 

 

First page

 

<?php

/*

Your cookie authentication goes here

*/

 

<form action="page2.php" method="post">

<input type="submit" value="test" name="proj_id_edit">

</form>

 

?>

 

This is just an illustration code..

Add your variable proj_id_edit into the form u have in the first page.

 

The page2.php is the code which i posted previously.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.