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

Sorry, forgot about this. And I didn't figure out yet how vB's AJAX system works...

I think this should do what you want.
Code:
<script type="text/javascript">
function create_req_object()
{
	var req = false;
	
	if (window.XMLHttpRequest)
	{
		req = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		var msp = new Array('Microsoft', 'Msxml2');
		
		for (var i in msp)
		{
			try
			{
				req = eval('ne' + 'w Act' + 'iveXObj'+ 'ect(msp[i] + ".XMLH'+ 'TTP");');
			}
			catch(e)
			{
				continue;
			}
		}
	}
	
	return req;
}

function submit_form(form)
{
	var http = create_req_object();
	
	if (!http)
	{
		return true;
	}

	if (isNaN(form.Home.value) || isNaN(form.Away.value))
	{
		alert("Invalid prediction. Please use numbers only.");
		return false;
	}

	http.open('POST', form.action);
	http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	http.onreadystatechange = function()
	{
		if (http.readyState == 4 && http.status == 200)
		{
			alert("Predictions successfully submitted.");
			
			fetch_object('Home1').innerHTML = form.Home.value;
			fetch_object('Away1').innerHTML = form.Away.value;
		}
	}
	http.send('do=addpredict&Home='+ form.Home.value +'&Away='+ form.Away.value +'&eventid='+ form.eventid.value +'&1Home='+ form.Home1.value +'&1Away='+ form.Away1.value);
	return false;
}

</script>
<form action="predictions.php" method="post" onsubmit="return submit_form(this);">
<input type="hidden" name="do" value="addpredict">
<input type="hidden" name="eventid" value="32">
<table class="tborder" cellspacing="1" cellpadding="4" border="0">
<tr><td class="tcat" colspan="5">Interactive game details</td></tr>
<tr><td class="thead">Your predictions</td><td class="thead">Actual</td><td colspan="2" align="center" class="thead">Teams</td><td class="thead">Colors</td></tr>

<div class="smallfont">

<tr><td align="center">
<input type="hidden" name="Home1" value="RDG">
<div id="Home1"><input name="Home" type="text" size="1" value=""></div>
</td><td class="alt2" align="center"></td><td nowrap>
<strong>Home</strong>:
</td><td>
RDG
</td><td><img src="images/calendarteams/RDG.gif">
</div>
</td></tr>

<div class="smallfont">

<tr><td align="center">
<input type="hidden" name="Away1" value="Victory">
<div id="Away1"><input name="Away" type="text" size="1" value=""></div>
</td><td class="alt2" align="center"></td><td nowrap>
<strong>Away</strong>:
</td><td>
Victory
</td><td><img src="images/calendarteams/Victory.gif">
</div>
</td></tr>

<div class="smallfont">

<strong>Venue</strong>:

Gonaives - Parc Vincent

</div>


<div class="smallfont">

<strong>Competition</strong>:

Digicel Cloture

</div>


<div class="smallfont">

<strong>Round</strong>:

9

</div>


<tr><td align="center"><input type="image" src="/forums/images/kirsch/buttons/predict.gif"></td><td">/buttons/predict.gif"></td><td class="alt2" style="border-top:0px solid #c0c0c0;" align="center" colspan="4">insert link to leaderboard here</td></tr>
</table>
</form>
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03664 seconds
  • Memory Usage 1,783KB
  • 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
  • (1)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