Hi
I am writing a php script that contains a bunch of links. Each link when clicked redirects to the same page however where the clicked link once was is now a textfield. The user then types into the text field once the user has entered input the page redirects to itself again this time where the text field was is a link again. The link is wutever the user typed into the previous text field. I am doing this by using $_REQUEST[....] to get wutever the user types in. So far Ive only been able to get one of these to work. The problem I am having is when the user clicks another link after the process is completed the previous process's variable is erased and the default link is outputted. Can someone help me with this problemF? I am posting a piece of my script.
Thanks
[PHP]$outer_link1 = "<a href=\"?Expand=outer_link1\" >outer_link1</a>";
if ($_REQUEST['Expand'] == "outer_link1")
{
$TextField1 = "<input type=text name=outer1 onChange='submit();' ";
echo("<td>$TextField1</td>");
}
else
{
$outer_link1_contents= $_REQUEST['outer1'];
if ($outer_link1_contents)
{
$outer_link1a = "<a href=\"?Expand=outer_link1\" >$outer_link1_contents</a>";
echo("<td>$outer_link1a</td>");
}
else
{
echo("<td>$outer_link1</td>");
}
}
$outer_link2 = "<a href=\"?Expand2=outer_link2\" >outer_link2</a>";
if ($_REQUEST['Expand2'] == "outer_link2")
{
$outer_link1_contents= $_REQUEST['outer1'];
if ($outer_link1_contents)
{
$outer_link1a = "<a href=\"?Expand=outer_link1\" >$outer_link1_contents</a>";
echo("<td>$outer_link1a</td>");
}
else
{
echo("<td>$outer_link1</td>");
}
$TextField2 = "<input type=text name=outer2 onChange='submit();' ";
echo("<td>$TextField2</td>");
}
else
{
$outer_link2_contents= $_GET['outer2'];
if ($outer_link2_contents)
{
$outer_link2a = "<a href=\"?Expand2=outer_link2\" >$outer_link2_contents</a>";
echo("$outer_link2a");
}
else
{
echo("<td>$outer_link2</td>");
}
} [/PHP]
18 1632
Hi,
Each time a user clicks a link they get a text box, completing the text box is supposed to change the text of the link. this works but only for one link at a time.
I think this is bacuase when you pist to a page it gets the page definition from the server and unless you change that file then you will always have this problem. what is happening is you are posting a vraibale to the target page and it's using it just fine. then with the second one it';s getting the original page as the file has not been updated.
To do what you want there are a couple of options open to you.
1. A database
Define the page based on a list of links in a table, then when a user makes a change to this the field in the table is updated and the page is redefined using the latest data from the database.
2. AJAX
When the user clicks a link simply display the text box without going to another page, then one ce the text is entered you can display the link again. This would be the same for each link and as it would never go and get the whole page from the server you would get teh desired results.
The deciding factor is really how permanent the change needs to be and should differnt users be able to set these things independantly of one another.
My prefered solution would be a combo of the database and AJAX.
Decide what exactly this system needs to do and for who and then pick a solution. Read up on the technology and post back here with any questions - I'm happy to try to help.
Cheers
nathj
Hi,
Each time a user clicks a link they get a text box, completing the text box is supposed to change the text of the link. this works but only for one link at a time.
I think this is bacuase when you pist to a page it gets the page definition from the server and unless you change that file then you will always have this problem. what is happening is you are posting a vraibale to the target page and it's using it just fine. then with the second one it';s getting the original page as the file has not been updated.
To do what you want there are a couple of options open to you.
1. A database
Define the page based on a list of links in a table, then when a user makes a change to this the field in the table is updated and the page is redefined using the latest data from the database.
2. AJAX
When the user clicks a link simply display the text box without going to another page, then one ce the text is entered you can display the link again. This would be the same for each link and as it would never go and get the whole page from the server you would get teh desired results.
The deciding factor is really how permanent the change needs to be and should differnt users be able to set these things independantly of one another.
My prefered solution would be a combo of the database and AJAX.
Decide what exactly this system needs to do and for who and then pick a solution. Read up on the technology and post back here with any questions - I'm happy to try to help.
Cheers
nathj
^^^^^^^^^^^^^^^^^^^^^^
Unfortunatly Im limited in how I can work on this. I dont have direct access to the database. And Im not allowed to create my own tables. So thats out.
As for AJAX...I had this working in javascript. The problem I had with that tho was that php wasnt able to access wutever I put in the javascript textfield. So thats also out.
Is there any other way to do this or am I trying the impossible at this point?
^^^^^^^^^^^^^^^^^^^^^^
Unfortunatly Im limited in how I can work on this. I dont have direct access to the database. And Im not allowed to create my own tables. So thats out.
As for AJAX...I had this working in javascript. The problem I had with that tho was that php wasnt able to access wutever I put in the javascript textfield. So thats also out.
Is there any other way to do this or am I trying the impossible at this point?
Okay so those in charge are making life difficult for you. I think though that AJAX can be your solution as the text fields are still just html text fileds. when the link is clicked simply load the text fields then on the submit of the text field call a JS function with the ID of the text field the JS can get the value and using the XMLHTTP Request object it can be passed to php page with the value on the end of the query string to be retreived by $_GET[].
I think this is the best bet you've got.
Cheers
nathj
I must admit I haven't looked very carefully at the code (since it is not complete), but have you thought of using the $_SESSION array as a way of saving these links?
Ronald
I must admit I haven't looked very carefully at the code (since it is not complete), but have you thought of using the $_SESSION array as a way of saving these links?
Ronald
I have no idea how to use SESSION. You got a link?
okay how do I use a session to retrieve the contents of a text field?
Would this work?
[PHP]
$TextField1 = "<input type=text name=outer1 onChange='submit();' >";
echo("$TextField1");
$_SESSION['outer1'] = $_REQUEST['outer1'];
echo("$_SESSION['outer1'] ");
[/PHP]
^^^^^^^^^^^^^^^^
Yea that code piece dont work. The only thing I cant figure out is how to retrieve the user input in the text field and then store it in a session variable.
^^^^^^^^^^^^^^^^
Yea that code piece dont work. The only thing I cant figure out is how to retrieve the user input in the text field and then store it in a session variable.
When you want to use the $_SESSION array you MUST start the session at the very beginning of your script, like
[php]<?php
session_start();
.. rest of code
[/php]
In your code sample that would be:
[php]
<?php
session_start();
$TextField1 = "<input type=text name=outer1 onChange='submit();' >";
echo("$TextField1");
$_SESSION['outer1'] = $_REQUEST['outer1'];
echo $_SESSION['outer1'];[/php]
Observe that the echo statement has been corrected because the original one would not show any output.
Ronald
okay I got the code to work. I still have the same problem that the value in the variable is being erased once I click a different link. Wut else can I do? Is there sumthing Im missing?
[PHP]
/* ########################### UNEXPAND ################################# */
$unexpand = "<a href=\"?Expand=Unexpand\" >Unexpand</a>";
echo("$unexpand");
session_start();
$outer_link1 = "<a href=\"?Expand=outer1\" >-0-</a>";
$TextField1 = "<input type=text name=outer1 onChange='submit();'>";
$_SESSION['outer1_value'] = $_REQUEST['outer1'];
if ($_REQUEST['Expand'] == "outer1")
{
//$textfield1_value = $_GET['outer1']
//value=$textfield1_value
echo("<td>$TextField1</td>");
}
elseif ( ($_REQUEST['Expand'] == "Unexpand")
|| ($_REQUEST['Expand'] !== "Unexpand") || ($_REQUEST['Expand'] !== "outer1"))
{
echo("should be a changed value");
if (!($_SESSION['outer1_value']))
{
$outer_link1 = "<a href=\"?Expand=outer1\" >-0-</a>";
echo("<td>$outer_link1</td>");
}
echo "<td>session value here<a href=\"?Expand=outer1\" >" . $_SESSION['outer1_value'] . "</td></a>";
}
else
{
echo("Do nothing");
}
[/PHP]
If you have a session_start() at the top of each script, you do the blanking out of the $_SESSION variable yourself.
Ronald
If you have a session_start() at the top of each script, you do the blanking out of the $_SESSION variable yourself.
Ronald
where should I put it then?
where should I put it then?
'
Sorry for my not-too-clear post. What I mean is that, when you correctly issue the session_start() at the top of each script, then no data in that $_SESSION array can be lost between pages.
So a blank entry in the array is your own doing.
Sorry for the misunderstanding.
Ronald
'
Sorry for my not-too-clear post. What I mean is that, when you correctly issue the session_start() at the top of each script, then no data in that $_SESSION array can be lost between pages.
So a blank entry in the array is your own doing.
Sorry for the misunderstanding.
Ronald
Its pretty much right at the top of the page. Im putting in the first few lines. Because the previous author of this script is using session variables for various db related processes. Should I destroy his old session before I start my own?
Theres the first few lines of my script
[PHP]
<?php
require("/scenarios/callable.php");
$db_conn = connect_db();
session_start();
.....
[/PHP]
You can leave the db-related vars in as long as you are sure that the 'require' script does not also start a session. That is why I would put in at the top right after the <?php statement.
Ronald
You can leave the db-related vars in as long as you are sure that the 'require' script does not also start a session. That is why I would put in at the top right after the <?php statement.
Ronald
nah that didnt work. Any other suggestions? Cuz I really got no other ideas on wut to do at this point.
nah that didnt work. Any other suggestions? Cuz I really got no other ideas on wut to do at this point.
Well I got it to work. Define the value of the session variable like this and add it to the rest of the code from the previous post
[PHP]$_SESSION['outer2_value'] = ($_REQUEST['outer2'])?$_REQUEST['outer2']:$_SESSION['outer2_value']; [/PHP]
Well I got it to work. Define the value of the session variable like this and add it to the rest of the code from the previous post
[PHP]$_SESSION['outer2_value'] = ($_REQUEST['outer2'])?$_REQUEST['outer2']:$_SESSION['outer2_value']; [/PHP]
Glad you, at last, found it yourself. See you next time.
Ronald
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mike |
last post by:
I can not figure out what is going on here. I hope somebody can please
help!!!
I've got an intranet ASP3 application running on a Win2k server. This
application requires a login, so the user...
|
by: Dan King |
last post by:
At a summary page, I am trying to clean up Session.Contents so the user can
go back to the main page and not retain any unnecessary info.
I have entered this into my summary page, but it seems to...
|
by: Clifford W. Racz |
last post by:
Has anyone solved the issue of translating lists in Word 2003 (WordML)
into xHTML? I have been trying to get the nested table code for my XSLT
to work for a while now, with no way to get the...
|
by: Geoff Cox |
last post by:
Hello,
How do I get the str_questions values into a form?! The following does
not work. I have also tried
document.write("<input type='hidden' name='slidervalues'
value=str_questions>");
...
|
by: Prince |
last post by:
I have a major problem. I have an entire HTML page
stored within a string variable.
ex.
<html><head><title>text</title></head>
<body>
some data
</body>
</html>
|
by: Andrew |
last post by:
Hey all,
Working on revamping our Intranet here and making use of the LDPA, Active
Directory, Directory Services, etc. that .Net provides. I am still fairly
new on this subject, so the problem...
|
by: COHENMARVIN |
last post by:
I have a form with a Submit button. The user fills out the form,
clicks the submit button, and then the page posts back to itself.
Every time the page posts back to itself, the "Page_Load" event...
|
by: Martin Chen |
last post by:
I have a frame set (as per MS FrontPage 2000). It has a contents and a main
frame. The contents frame has a menu bar written with with javascript (in
the context of a table). In IE6.1 everything...
|
by: venkatagmail |
last post by:
I have problem understanding pass by value and pass by reference and
want to how how they are or appear in the memory:
I had to get my basics right again. I create an array and try all
possible...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |