# Eraatic Help please

**URL:** <https://www.phphelp.com/t/eraatic-help-please/33232>\
**Category:** Javascript & Ajax\
**Created:** [March 9, 2021, 5:26am UTC](https://www.phphelp.com/t/eraatic-help-please/33232 "2021-03-09T05:26:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmanghani](https://www.phphelp.com/letter_avatar_proxy/v4/letter/d/e9c0ed/32.png) [@dmanghani](https://www.phphelp.com/u/dmanghani)\
**Post date:** [March 9, 2021, 5:26am UTC](https://www.phphelp.com/t/eraatic-help-please/33232/1 "2021-03-09T05:26:40Z")

</div>

The code works the first time around, the second time around only the checkboxes get clicked but no prompts

```auto

<label><input type="checkbox" name="install" <?php if(isset($_GET['install'])) { echo 'checked'; } ?>
id='install' value="Install" onchange="this.form.submit()"> Install & Comm</label>
<label><input type='checkbox' name='freight' <?php if(isset($_GET['install'])) { echo 'checked'; } ?>
id='freight' value='freight' onchange='this.form.submit()'> Freight Charges</label> 
<label><input type='checkbox' name='discount' <?php if(isset($_GET['install'])) { echo 'checked'; } ?>
id='discount' value='discount' onchange='this.form.submit()'> Discount</label>       
<script>
    function getValueInstall() {
var installAmount = prompt("Enter Install Value");
      if (installAmount>0) {
      window.location.href = (window.location.href.split('?')[0]) + "? install=on + p1=install &installp2=" + installAmount;
      } else {
            window.location.href = (window.location.href.split('?')[0]) + "? p1=install& p2=" + installAmount;     
      }
}
document.getElementById("install").onclick = getValueInstall;
    function getValueFreight() {
var freightAmount = prompt("Enter Freight Value");
      if (freightAmount>0) {
      window.location.href = (window.location.href.split('?')[0]) + "? freight=on + p1=freight &freightp2=" + freightAmount;
      } else {
            window.location.href = (window.location.href.split('?')[0]) + "? p1= & p2=" ;     
      }
}
document.getElementById("freight").onclick = getValueFreight;
    function getValueDiscount() {
var discountAmount = prompt("Enter Discount Value");
      if (discountAmount>0) {
      window.location.href = (window.location.href.split('?')[0]) + "? discount=on + p1=discount & discountp2=" + discountAmount;
      } else {
            window.location.href = (window.location.href.split('?')[0]) + "? p1= & p2=" ;     
      }
}
document.getElementById("discount").onclick = getValueDiscount;
</script>

```

---

<div class="post-metadata">

**Author:** ![phdr](https://www.phphelp.com/letter_avatar_proxy/v4/letter/p/91b2a8/32.png) [@phdr](https://www.phphelp.com/u/phdr)\
**Post date:** [March 9, 2021, 4:58pm UTC](https://www.phphelp.com/t/eraatic-help-please/33232/2 "2021-03-09T16:58:47Z")

</div>

You need to use your browser’s developer tools/console tab and also view the source of the page in your browser to investigate what is occurring. You are getting an error about trying to set the onclick property on a null value. This is because there’s no space between the ‘checked’ keyword and the id=’…’. attribute. You end up with **checkedid** =’…’, so, when the javascript tries to use getElementBy **Id** ("…"), there are no id attributes at all in the markup.

In addition to that issue, there are some typographic mistakes in the code. The php isset() tests are all using the same element and all the extra spaces and + characters, **inside** the strings in the javscript are incorrect and are not producing the expected/valid URLs (take a look at your browser’s address bar.)

---

<div class="post-metadata">

**Author:** ![dmanghani](https://www.phphelp.com/letter_avatar_proxy/v4/letter/d/e9c0ed/32.png) [@dmanghani](https://www.phphelp.com/u/dmanghani)\
**Post date:** [March 16, 2021, 9:15am UTC](https://www.phphelp.com/t/eraatic-help-please/33232/3 "2021-03-16T09:15:02Z")

</div>

thanks will check it out
