Hey guys, I'm a noob in javascript and want to know what I'm doing wrong. What I'm trying to do basically is hava a select menu determine where my strings are to be stored. Here is what I'm doing:
The code:
<form id="form1" name="form1" method="post" action="push.php">
<select name="ga" id="ga" onchange="gameApp(this);">
<option value="game">Game</option>
<option value="app">App</option>
</select><br/>
App/Game Name:
<input type="text" name="n" id="n" />
*<br />
Author:
<input type="text" name="a" id="a" />
*<br />
Version:
<input type="text" name="v" id="v" />
<br />
Icon:
<input type="text" name="i" id="i" />
*<br />
Download Link:
<input type="text" name="l" id="l" />
*<br />
Description:
<input type="text" height="80px" name="d" id="d" />
<br />
Screenshot:
<input type="text" name="s" id="s" /><br />
<input type="text" name="s2e" id="s2e" /><br />
<input type="text" name="s3" id="s3" /><br />
<input type="text" name="s4" id="s4" /><br />
<input type="text" name="s5" id="s5" />
<br />
App Size (MB):
<input type="text" name="s2" id="s2" />
<br />
Original Link (windows market, itunes, etc):
<input type="text" name="o" id="o" />
<br />
Device Profile
<input type="text" name="device" id="device"/>
*
<input type="submit" name="submit" id="submit" value="Submit" />
</form>
<?php
// Fetch APP DETAILS
$n = stripslashes($_POST['n']);
$a = stripslashes($_POST['a']);
$v = stripslashes($_POST['v']);
$i = stripslashes($_POST['i']);
$l = stripslashes($_POST['l']);
$d = stripslashes($_POST['d']);
$s = stripslashes($_POST['s']);
$s2e = stripslashes($_POST['s2e']);
$s3 = stripslashes($_POST['s3']);
$s4 = stripslashes($_POST['s4']);
$s5 = stripslashes($_POST['s5']);
$s2 = stripslashes($_POST['s2']);
$o = stripslashes($_POST['o']);
$device = stripslashes($_POST['device']);
if($n != ""){
// Create the file
$file =
"\n"
. $n . "(.)\n"
. $a . "(.)\n"
. $v . "(.)\n"
. $i . "(.)\n"
. $l . "(.)\n"
. $d . "(.)\n"
. $s . "(.)\n"
. $s2e . "(.)\n"
. $s3 . "(.)\n"
. $s4 . "(.)\n"
. $s5 . "(.)\n"
. $s2 . "(.)\n"
. $o . "(.)\n"
. $device . "(.)";
}
?>
<!-- The part that doesnt work-->
<script type="text/javascript">
function gameApp(selection) {
if (selection.value === "app") {
document.write(<?php file_put_contents('../apps/page1/raw_data.txt', $file, FILE_APPEND);?>));}
if (selection.value=== "game"{
document.write(<?php file_put_contents('../games/page1/raw_data.txt', $file, FILE_APPEND);?>));}
}
</script>
Thanks in advance