# Passing variable from onclick to href

**URL:** <https://forum.kirupa.com/t/passing-variable-from-onclick-to-href/178890>\
**Category:** Uncategorized\
**Created:** [February 15, 2006, 2:48am UTC](https://forum.kirupa.com/t/passing-variable-from-onclick-to-href/178890 "2006-02-15T02:48:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DHDesign](https://avatars.discourse-cdn.com/v4/letter/d/b19c9b/32.png) [@DHDesign](https://forum.kirupa.com/u/DHDesign)\
**Post date:** [February 15, 2006, 2:48am UTC](https://forum.kirupa.com/t/passing-variable-from-onclick-to-href/178890/1 "2006-02-15T02:48:49Z")

</div>

hi, so i have the following:

```auto
 
<a onclick="validate();" href="">Delete</a>

```

brief overview: user selects checkboxes from table and hits delete…validate() gets the values of the checkboxes & also checks if any checkboxes have been selected at all.

```auto
function validate(form) {
var total="";
for(var i=0; i < document.form.checkedoff.length; i++){
  if(document.form.checkedoff*.checked){
    total +=document.form.checkedoff*.value + "
";
  }
}
if(total=="")
  {
    alert("You must select User(s) for this operation first.")
    return false;
  } else {
    alert (total);
    return total;
  }
}

```

what i need is to have the values of the checkboxes returned to me from validate() and then put into the href tag for php to use and delete the selected records.

kinda like this, but obviously this would not work:

```auto
 
<a onclick="var checked = validate();" href="delete.php?id=checked">Delete</a>

```

please help! thanks!!!
