Hola,
bueno aver
si te entendi...
Código HTML:
<script type="text/javascript">
function agregarVariables(){
var i1 = document.getElementById("i1");
var i2 = document.getElementById("i2");
if( !/\?/g.test(this .href) ){
i1 = ( i1.value!="" ) ? "i1="+ i1.value : "";
i2 = ( i2.value!="" ) ? "i2="+ i2.value : "";
var s = ( i1=="" && i2=="" ) ? "" : "?";
if( i1=="" || i2=="" )
this .href = this .href + s + i1 + i2;
else if( i1!="" && i2!="" )
this .href = this .href + s + i1 +"&"+ i2;
}
//return false;
};
</script>
<input type="text" id="i1" /><br>
<input type="text" id="i2" /><br><br>
<a href="link.php" id="elLink" onclick="agregarVariables.call(this);">link</a>
SAludos...
:]