A Problem related to loosing its value
Posted: Thu Aug 04, 2005 5:24 pm
Hi,
I have this code (from search.php - search engine):
I want to add some information to the string of "str", until I click the createBib button when I click the searchMore button. It works fine for the first search, but when I clicl the searchMore button it makes the value of "str", undefined (However, I want to add the new information to the tail of before information). After this search, if I search for another thing, it will make "undefined" the value of str.
How I can solve this problem?
NOTE: I konw thata it is mostly JavaScript code, but maybe there is a way with PHP:
I have this code (from search.php - search engine):
Code: Select all
<?php
if(!isset($str))
$str = "";
?>
<script language="javascript">
var str;
function get_index(n)
{
for(i = 0;i < n; i++)
{
if(document.getElementById("ctrl_bib"+i).checked)
{
str = str + "," + document.getElementById("ctrl_bib"+i).value;
}
}
}
function search_more(n)
{
get_index(n);
window.location.href = './search.php?str='+str;
}
function create_bib(n2)
{
get_index(n2);
window.location.href = './createbib.php?current='+str;
str = "";
}
</script>I want to add some information to the string of "str", until I click the createBib button when I click the searchMore button. It works fine for the first search, but when I clicl the searchMore button it makes the value of "str", undefined (However, I want to add the new information to the tail of before information). After this search, if I search for another thing, it will make "undefined" the value of str.
How I can solve this problem?
NOTE: I konw thata it is mostly JavaScript code, but maybe there is a way with PHP: