1
function check(id){
    var _id = document.getElementById(id);
    url = "test.php?check=1&id=" + _id;
}

i want the id in the url it's working but without the id that is in the check('123');

It's for an innerHTML to load something

hope you can help me with getting the id

Greetings

1
  • Can you post more of your code so we can understand whatyou are trying to achieve Commented May 13, 2009 at 9:39

2 Answers 2

4

The document.getElementId() function returns an object value based on the identifier string (ID) that you supply; therefore if you have an element on your page with the id of foo then you call

document.getElementById("foo");

to return the object for that element, so that you can manipulate it (changing styles, or attributes etc).

If you want to insert the id into the URL of the test.php page, why not simply pass the identifier string of the element that you pass in with the function?:

function check(id){
    url = "test.php?check=1&id=" + id;
}

Then calling

check("123");

will set the url variable to test.php?check=1&id=123

Sign up to request clarification or add additional context in comments.

Comments

2
var _id = document.getElementById(id).id;

2 Comments

Either the OP is unaware that .id will = the input to getElementById or this isn't what the OP wants, which is admittedly rather hard to decipher.
hi there, now i don't get anything before it gave me ?check=1&id=null i need to get ?check=1&id=123 thanks for the quick answer

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.