View Single Post
  #15  
Old 10-19-2006, 11:14 AM
nico_swd's Avatar
nico_swd nico_swd is offline
 
Join Date: Dec 2005
Location: Spain
Posts: 170
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

^^ Thank you for that. I'll have a look at it.

Lionel, I just downloaded your script. Thanks for the credit.

I saw you modified it a bit... don't use getElementById, cause it's not cross browser safe. Use vB's fetch_object() function instead.

Code:
fetch_object('button'+ form.eventid.value).innerHTML = '<a href="predictions.php?do=remove&eventid='+ form.eventid.value +'">Remove</a>';
Also, I'll have a look on how to make it compatible with vB's AJAX system and post an updated version later.


EDIT:

Give this a try.
Code:
function submit_form(form)
{
	if (isNaN(form.Home.value) || isNaN(form.Away.value) || !form.Home.value || !form.Away.value)
	{
		alert("Invalid prediction. Please use numbers only.");
		return false;
	}
	
	http = new vB_AJAX_Handler(true);
	
	if (!http)
	{
		return true;
	}

	http.onreadystatechange(handle_prediction);
	http.send('predictions.php', 'do=addpredict&Home='+ form.Home.value +'&Away='+ form.Away.value +'&eventid='+ form.eventid.value +'&1Home='+ form.Home1.value +'&1Away='+ form.Away1.value);
	return false;
}


function handle_prediction()
{
	if (http.handler.readyState == 4 && http.handler.status == 200)
	{
		var form = document.predictions;
		
		fetch_object('Home'+ form.eventid.value).innerHTML = form.Home.value;
		fetch_object('Away'+ form.eventid.value).innerHTML = form.Away.value;
		fetch_object('button'+ form.eventid.value).innerHTML = '<a href="predictions.php?do=remove&eventid='+ form.eventid.value +'">Remove</a>'
		
	}
}
You have to change the form name to "predictions", or change predictions to something else in the second function.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01900 seconds
  • Memory Usage 1,764KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete