0

I am trying to alert a number with a hyphen in it, however it keeps calculating the number instead...

HTML / PHP
    echo '<input type="submit" name="remove" value="remove" onclick="removeEntry(' .
          $row['Incident'] . ',' . $row['Fogbugz Number'] . ')" />';

This has been tested and returns the correct values to the form (checked the source for the page)

"onClick="removeEntry(123456-001111, 123456)"

Here is what happens when I try the javascript:

Javascript
    function removeEntry(incident, fogbugz){
        alert(incident);
    }

this causes an alert box with 122345. However I want it to return "123456-001111"

I have tried:

alert(toString(incident));

alert(incident.toString());

alert(str(incident));

alert(incident.value);

incident = incident.value
alert(incident);

I cannot figure this one out :(

1
  • Show your rendered HTML, not your PHP: JavaScript is client-side. Apr 12, 2012 at 17:38

2 Answers 2

2

Try passing the argument as a string in the first place; something like:

onClick="removeEntry('123456-001111',123456);"

The way you have it now, the numbers are subtracted from each-other as the page code loads.

0

Look at what you are doing:

onClick="removeEntry(123456-001111, 123456)

You are subtracting two numbers, not displaying a string. It needs quotes!

onClick="removeEntry('123456-001111', 123456)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.