Pool Installation - Insurance Articles Directory - Debt Consolidation - Thailand Property - Debt Consolidation

PDA

View Full Version : Window.location.href cuts off parameter


fex
Apr 19th 2009, 6:59 am
Hello,

I've got a news and guestbook system created on my website working with use of a database. The id (in my database table) is being used to remove a post.

A jscript does the following:
function confirmRemove(var_id){
if(confirm('Wilt u deze post echt verwijderen?')){
window.location.href = 'index.php?page=gastenboek&do=remove&id=' + var_id + '#anc';
}
}

When I hover over a link directed to this function the var_id is correct (let's say the id is 090414144354). But when I click the link the var_id is missing the leading zero (so the id becomes 90414144354). This causes my file not to be deleted of course cause it is not found.

joep1978
Apr 19th 2009, 8:16 am
The problem looks like Javascript is treating the parameter like an integer, not a string. Integers don't have leading zeros.

I don't know how you're calling the function but confirmRemove(090414144354); would cause this problem - you'd need to do confirmRemove('090414144354');

fex
Apr 19th 2009, 8:59 am
You're totally right, guess I was looking too hard.

Thx ;)