Jump to content

jquery or javascript - script help


Destramic

Recommended Posts

im looking for a script which allows you to selected a certian option on a form select box then a row of list boxes will show underneath depending on what the select box value is....does anyone know of a good link to such a script/site/tutorial

 

if you dont understand let me know please...thank you

Link to comment
https://forums.phpfreaks.com/topic/201855-jquery-or-javascript-script-help/
Share on other sites

im finnal on to something now...but the script im trying to function keeps returning an error on the json "failed to submit"...can anyone tell me why please

 

<!DOCTYPE html>
<html>
<head>
  <script type="text/javascript" src="/ajax/jquery/libary/jquery.js"></script>
</head>
<body>
<?php 
$game_type = array();
$division  = array();

if ($_POST['game'] == 1)
{
$game_type[] = array('value' => '1',
	                 'text' => 'TDM'
);

    $division[] = array('value' => '1',
	                 'text' => 'Divison 1'
);
}
elseif ($_POST['game'] == 2)
{
$game_type[] = array('value' => '1',
	                 'text' => 'CTF'
);

    $division[] = array('value' => '1',
	                 'text' => 'Divison 2'
);
}

json_encode($game_type);
json_encode($division);
?>
<form>
<script>	
$(document).ready(function(){
$("select#game").change(function(){

	$.ajax({
		type: 'POST',
        data: 'data',
        dataType: 'json',
        cache: false,
        url: 'json.php',
        timeout: '2000',
        error: function() {
        	alert("Failed to submit");
        },
        success: function(data) { 
        	alert("working!");
			 }
	});

        //	$('#game_type').html('<input type=\"checkbox\" value=\"test\" /> TDM'); 
        //   $('#division').html('<input type=\"checkbox\" value=\"test\" /> Division 1'); 

});
});

</script>
<select name="game" id="game">
<option value=""></option>
<option value="1">Counter Strike</option>
<option value="2">COD</option>
</select>

<div id="game_type">
</div>
<div id="division">
</div>
</form>

</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.