Forums

is null or not an object

juzwant2play 16 Feb, 2010
I am having so much trouble over something that should be real simple. Can anyone help me as to what I am doing wrong?


Error Message



Message: 'document.ChronoContact_junk.totalcost' is null or not an object
Line: 128
Char: 1
Code: 0
URI: http://www.threegatesfestival.org/index.php?option=com_chronocontact&chronoformname=junk



Javascript Code


function updatesum()
{
var c = 5;
document.ChronoContact_junk.totalcost.value = c;
}


Form code:


<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Name</label>
    <input class="cf_inputbox" maxlength="150" size="30" title="" id="text_0" name="name1" type="text" onChange="updatesum()"/>
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Age</label>
    <select class="cf_inputbox" id="select_1" size="1" title=""  name="age1" onChange="updatesum()">
    <option value="0">Choose Option</option>
      <option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Name</label>
    <input class="cf_inputbox" maxlength="150" size="30" title="" id="text_2" name="name2" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Age</label>
    <select class="cf_inputbox" id="select_3" size="1" title=""  name="age2" onChange="updatesum()">
    <option value="0">Choose Option</option>
      <option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>

    </select>
    
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Total Cost</label>
    <input class="cf_inputbox" maxlength="150" size="30" title="" id="text_4" name="totalcost" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>
GreyHead 17 Feb, 2010
Hi juzwant2play,

There is no element with an id of 'totalcost'
. . . id="text_4" name="totalcost" . . .


Bob
juzwant2play 17 Feb, 2010
Thanks for the reply. I am still getting the same error after adding the id tag.

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Name</label>
    <input class="cf_inputbox" maxlength="150" size="30" title="" id="text_0" name="name1" type="text" onChange="updatesum()" />
  
  </div>
  <div class="cfclear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label" style="width: 150px;">Total Cost</label>
    <input class="cf_inputbox" maxlength="150" size="30" title="" id="totalcost" name="totalcost" type="text" />
  
  </div>
  <div class="cfclear"> </div>
</div>



function updatesum()
{
var c = 5;
document.ChronoContact_junk.totalcost.value = c;
}

GreyHead 17 Feb, 2010
Hi juzwant2play,

I think this is because you have the form twice in the page so the id isn't unique.

Bob
juzwant2play 17 Feb, 2010
The form is only once on the page and the id is definitely unique. I copied the form code and javqascript code directly from the appropriate sections in chronoforms.
GreyHead 17 Feb, 2010
Hi juzwant2play,

I'm pretty certain that last time I looked the form was in teh page body and in a module at the bottom of the right hand column. The second copy and the error are both gone now as far as I can see.

Bob
This topic is locked and no more replies can be posted.