• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I keep getting on Javascript Error on the bottom left of IE

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I created a text file that is the "face" of my survey question on Sharepoint 2010(it sits on the front page in Web content editor), and I have it connected and it's working well but it will not display a message saying that is was submitted successfully....what is happeneing?

I also would LOVE to have the survey "dissapear" after it's been answered, is this possible if not is there antoher way to do something similiar?

Below is the code....



<div onkeydown='javascript:if (event.keyCode == 13) postSurvey()'>
<p>Are you attending Friday Lunch?<br />
<input name='q1' id='q1Yes' type='radio' value='Yes'/><label for='q1Yes'> Yes</label><br />
<input name='q1' id='q1No' type='radio' value='No'/><label for='q1No'> No</label><br />
</p>
<p>Are you a vegetarian?<br />
<input name='q2' id='q2Yes' type='radio' value='Yes'/> <label for='q2Yes'> Yes</label><br />
<input name='q2' id='q2No' type='radio' value='No' /><label for='q2No'> No</label><br />
</p>
<p>How many guests do you have?<br />
<input name='q3' id='q30' type='radio' value='0'/> <label for='q30'> 0</label>
<input name='q3' id='q31' type='radio' value='1' /><label for='q31'> 1</label>
<input name='q3' id='q32' type='radio' value='2'/> <label for='q32'> 2</label><br />
<input name='q3' id='q33' type='radio' value='3' /><label for='q33'> 3</label>
<input name='q3' id='q34' type='radio' value='4'/> <label for='q34'> 4</label>
<input name='q3' id='q35' type='radio' value='5' /><label for='q35'> 5</label>
</p>
<input type='button' value='Submit' onclick='javascript:postSurvey();' />
</div>
<script src='/_layouts/SP.js' type='text/javascript'></script>
<script language='javascript' type='text/javascript'>

/* Returns the value of the input element that is checked.
Accepts either an array or a single input element of
type radio or checkbox.
Returns an empty string if none are checked or if
there are no radio buttons or check boxes.
*/
function getCheckedValue(buttonGroup) {
if (!buttonGroup)
return '';
var objLength = buttonGroup.length;
if (objLength == undefined) {
if (buttonGroup.checked)
return buttonGroup.value;
else
return '';
}
for (var i = 0; i < objLength; i++) {
if (buttonGroup[i].checked)
return buttonGroup[i].value;
}
return '';
}

function postSurvey() {

// Retrieve the radio button values
var question1 = getCheckedValue(document.getElementsByName('q1'));
var question2 = getCheckedValue(document.getElementsByName('q2'));
var question3 = getCheckedValue(document.getElementsByName('q3'));

/* Validate the response.
Do nothing more until all questions are answered.
*/
if (question1 == '' || question2 == ''|| question3 == '') {
alert('Please answer all questions.')
return;}
{
// Get the current context
var context = new SP.ClientContext.get_current();

// Get the current site (SPWeb)
var web = context.get_web();

// Get the survey list
var list = web.get_lists().getByTitle('FridayLunch');

// Create a new list item
var itemCreateInfo = new SP.ListItemCreationInformation();
var listItem = list.addItem(itemCreateInfo);

/* Set fields in the item.
In managed code, this would be listItem[fieldname] = value.
In Javascript, call listItem.set_item(fieldName,value).
*/
listItem.set_item('Are_x0020_you_x0020_attending_x0', question1);
listItem.set_item('Are_x0020_you_x0020_a_x0020_vege', question2);
listItem.set_item('How_x0020_many_x0020_guests_x002', question3);
listItem.update();

// Create callback handlers
var success = Function.createDelegate(this, this.onSuccess);
var failure = Function.createDelegate(this, this.onFailure);
}

// Execute an async query
context.executeQueryAsync(success,failure);

// Async query succeeded.
function onSuccess(sender, args) {

alert('Thank You for Responding to Friday Lunch!');

// Refresh the page.
SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
}

// Async query failed.
function onFailure(sender, args) {
alert(args.get_message());
}}

</script>
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error message is?

IE8+ have a good debugger built into the browser.

Eric
 
Christ Gove
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Eric Pascarello wrote:The error message is?

IE8+ have a good debugger built into the browser.

Eric



There isn't an actual message that pops up when you submit....that's the problem.....i just notice the little warning sign in the bottom left............The reason I know it works is because it populates the survey and also if you don't fill all of the questions out it tells you to fill in all the bubbles before you can continue.....

I want it ti say "thank you " once you submit the information and then somehow have a lookup that knows you've submitted it via the "user" and then show some sort of image or have it disappear

Thanks for the help in advance!!
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Learn to debug, click on it and it gives you the error.

Eric
 
Christ Gove
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't seem to figure out how to make this not pop up,.,,,,



Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C)
Timestamp: Tue, 10 Jan 2012 19:29:04 UTC


Message: 'SP.ScriptUtility' is null or not an object
Line: 2
Char: 284632
Code: 0
URI: http://om-shrpoint02/_layouts/SP.js


Message: 'b' is null or not an object
Line: 5
Char: 298
Code: 0
URI: http://om-shrpoint02/ScriptResource.axd?d=hOCpnsNabm-n6ES6X2YhCWPXn6tfhbW-335Y_S5cN-SK-FAdNnJjGUkSCv_Aknq_4mGFisdzgjoYz1kveI27nldgOYrje0BRAN-82cpFpe2ogLhMwkhJc40beZN_wTeDcTtHJ6ryjsyTMCilbz2thIy5xus1&t=fffffffff9d85fa6





 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like you are using sharepoint, you might want to ask this some place that has a bunch of shareoint users.

Null or not an object means a function is called before the element/object is loaded.

Eric
 
Christ Gove
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Eric
 
He was giving me directions and I was powerless to resist. I cannot resist this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic