0

Hi there i currently have a PHP code where i need to pass the $value into the onclick function in order to call the javascript function to refresh my page. But if i pass a string value something like this "Cat 2" into the $value, i tried to inspect the javascript console on the $value it show me like this

<a href="#" onclick="filterRules('Cat" 2',2)="">2</a>

Where is automatically split my string value, what is suppose to have is something like this

2

Here is my example code for the link:

for($i=1;$i<=$total;$i++)
{
    if($i==$id) { $link = $link. "<li class='current'>".$i."</li>"; }
    else { $link = $link. "<li><a href='#' onclick = filterRules('".$value."',$i)>$i</a></li>"; }

}

Is there any single quote or double quote i place wrongly? Please point it out for me thanks.

EDITED: the $value is pass from user input where it will be "Cat 2" , not "Cat" "2" like what John had mark my question as duplicated. Thanks

Marcus Tan
  • 407
  • 1
  • 9
  • 26
  • where is $value calculated ? its hard to tell from the link example exactly what the value of $value is supposed to be. i dont know whether the single and double quotes are coming from the variable or elsewhere – lonewolf217 Apr 15 '15 at 17:40
  • $value = $_GET['value']; It was get from the value that user pass as a string – Marcus Tan Apr 15 '15 at 17:43
  • @John Conde I don't know why you mark this as a duplicate question, the link that u put for combining 2 string is not what i want. can u be more specify on what part did i duplicate on? – Marcus Tan Apr 15 '15 at 17:44
  • @JohnConde Those answer was about data1. ' ' . data2 Where my string is only in one string value. – Marcus Tan Apr 15 '15 at 17:49
  • Yes, i had try to research before i posted, but i had try most of the concatenation solution but none of them are working on mine, that is why i posted the question here and ask for a expert to point out my error. – Marcus Tan Apr 15 '15 at 17:51

0 Answers0