var doesn't keep value, only in the console.log
I have some problem that i dont get my head arround... I want the variable of eId to be added to the data string but it always comes up as 0, but in the console log it shows the value changing... how can i add the eId value to it. Here is the code:
- <?php require_once('Connections/dbconnection.php'); ?>
- <?php
- if (!function_exists("GetSQLValueString")) {
- function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
- {
- if (PHP_VERSION < 6) {
- $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
- }
- $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
- switch ($theType) {
- case "text":
- $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
- break;
- case "long":
- case "int":
- $theValue = ($theValue != "") ? intval($theValue) : "NULL";
- break;
- case "double":
- $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
- break;
- case "date":
- $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
- break;
- case "defined":
- $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
- break;
- }
- return $theValue;
- }
- }
- mysql_select_db($database_dbconnection, $dbconnection);
- $query_eventImages = "SELECT id, status, eventName, eventStart, bigPic FROM events WHERE status = 1 ORDER BY eventStart ASC";
- $eventImages = mysql_query($query_eventImages, $dbconnection) or die(mysql_error());
- $row_eventImages = mysql_fetch_assoc($eventImages);
- $totalRows_eventImages = mysql_num_rows($eventImages);
- mysql_select_db($database_dbconnection, $dbconnection);
- $query_htmlcaption = "SELECT id, eventName FROM events WHERE status = 1 ORDER BY eventStart ASC";
- $htmlcaption = mysql_query($query_htmlcaption, $dbconnection) or die(mysql_error());
- $row_htmlcaption = mysql_fetch_assoc($htmlcaption);
- $totalRows_htmlcaption = mysql_num_rows($htmlcaption);
- ?>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <html lang="en">
- <style type="text/css">
- body,td,th {
- color: #CCC;
- }
- </style>
- <head>
- <title>None</title>
- <link rel="stylesheet" href="themes/default/default.css" type="text/css" media="screen" />
- <link rel="stylesheet" href="themes/light/light.css" type="text/css" media="screen" />
- <link rel="stylesheet" href="themes/dark/dark.css" type="text/css" media="screen" />
- <link rel="stylesheet" href="themes/bar/bar.css" type="text/css" media="screen" />
- <link rel="stylesheet" href="nivo-slider.css" type="text/css" media="screen" />
- <link rel="stylesheet" href="style.css" type="text/css" media="screen" />
- <link rel="stylesheet" href="css/dark-hive/jquery-ui-1.9.0.custom.min.css" type="text/css"/>
-
- <style>
- body {
- font-size: 62.5%;
- background-image: url(images/bg001.jpg);
- background-repeat: no-repeat;
- background-position: center top;
- background-color: #000;
- }
- label, input { display:block; }
- input[type=radio], .radio { display: inline; }
- input.text { margin-bottom:12px; width:95%; padding: .4em; }
- fieldset { padding:0; border:0; margin-top:25px; }
- h1 { font-size: 1.2em; margin: .6em 0; }
- div#users-contain { width: 350px; margin: 20px 0; }
- div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 100%; }
- div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
- .ui-dialog .ui-state-error { padding: .3em; }
- .validateTips { border: 1px solid transparent; padding: 0.3em; }
- </style>
- <script type="text/javascript" src="js/jquery-1.8.2.js"></script>
- <script type="text/javascript" src="js/jquery-ui-1.9.0.custom.min.js"></script>
- <script type="text/javascript" src="jquery.nivo.slider.js"></script>
- <script type="text/javascript">
- $(window).load(function() {
- $('#slider').nivoSlider();
- });
- </script>
- <script>
- $(function() {
- $( "#dialog:ui-dialog" ).dialog( "destroy" );
-
- $("input:radio[name=eventSel]").click(function() {
- var eId = $(this).attr("value");
- // output to console for eId
- console.log(eId);
- })
-
- var firstName = $( "#firstName" ),
- lastName = $( "#lastName" ),
- emailAddress = $( "#emailAddress" ),
- allFields = $( [] ).add( firstName ).add( lastName ).add( emailAddress ),
- tips = $( ".validateTips" );
- function updateTips( t ) {
- tips
- .text( t )
- .addClass( "ui-state-highlight" );
- setTimeout(function() {
- tips.removeClass( "ui-state-highlight", 1500 );
- }, 500 );
- }
- function checkLength( o, n, min, max ) {
- if ( o.val().length > max || o.val().length < min ) {
- o.addClass( "ui-state-error" );
- updateTips( "Length of " + n + " must be between " +
- min + " and " + max + "." );
- return false;
- } else {
- return true;
- }
- }
- function checkRegexp( o, regexp, n ) {
- if ( !( regexp.test( o.val() ) ) ) {
- o.addClass( "ui-state-error" );
- updateTips( n );
- return false;
- } else {
- return true;
- }
- }
-
- $( "#dialog-form" ).dialog({
- autoOpen: false,
- height: 425,
- width: 375,
- modal: true,
- buttons: {
- "Sign Up": function() {
- var bValid = true;
- allFields.removeClass( "ui-state-error" );
- bValid = bValid && checkLength( firstName, "firstName", 2, 40 );
- bValid = bValid && checkLength( lastName, "lastName", 2, 40 );
- bValid = bValid && checkLength( emailAddress, "emailAddress", 5, 60 );
- if ( bValid ) {
-
- $.ajax({
- type: "POST",
- url: "crud.php?act=create",
- data: "firstName=" + firstName.val() + "&lastName=" + lastName.val() + "&emailAddress=" + emailAddress.val() + "&eventId=" + $eId,
- success: function(data){
-
- }
- });
-
- $( this ).dialog( "close" );
- }
- },
- Cancel: function() {
- $( this ).dialog( "close" );
- }
- },
- close: function() {
- allFields.val( "" ).removeClass( "ui-state-error" );
- }
- });
- $('#openMe').click(function() {
- $( "#dialog-form" ).dialog( "open" );
- });
- });
- </script>
- </head>
- <body>
- <div id="wrapper">
- <a href="http://www.visionshocklosangeles.com" id="logolink" title="Go to Visionshock Los Angeles">VS LA</a>
- <div class="signup">
- <div id="dialog-form" title="Guest List Sign Up">
- <p class="validateTips">All form fields are required.</p>
- <form>
- <fieldset>
- <?php do { ?>
- <label>
- <input type="radio" name="eventSel" value="<?php echo $row_htmlcaption['id']; ?>">
- <?php echo $row_htmlcaption['eventName']; ?></label>
- <?php } while ($row_htmlcaption = mysql_fetch_assoc($htmlcaption)); ?>
- <br>
- <label for="firstName">First Name</label>
- <input type="text" name="firstName" id="firstName" class="text ui-widget-content ui-corner-all" value=""/>
- <label for="lastName">Last Name</label>
- <input type="text" name="lastName" id="lastName" class="text ui-widget-content ui-corner-all" value=""/>
- <label for="emailAddress">Email Address</label>
- <input type="text" name="emailAddress" id="emailAddress" class="text ui-widget-content ui-corner-all" value=""/>
- </fieldset>
- </form>
- </div>
- </div>
- <div class="slider-wrapper theme-dark">
- <div><img id="openMe" src="images/btn_guestlist.png" width="140" height="72"><a href="mailto:tables@visionshocklosangeles.com"><img src="images/btn_table.png" width="140" height="72"></a></div>
- <div id="slider" class="nivoSlider">
- <?php do { ?>
- <img src="images/<?php echo $row_eventImages['bigPic']; ?>" alt="<?php echo $row_eventImages['eventName']; ?>" data-transition="boxRandom" title="#htmlcaption_up<?php echo $row_eventImages['id']; ?>" />
- <?php } while ($row_eventImages = mysql_fetch_assoc($eventImages)); ?>
- </div>
-
-
-
- <div id="htmlcaption_up<?php echo $row_htmlcaption['id']; ?>" class="nivo-html-caption"> For Guestlist sign up please click here, <a href="#">Guestlist</a> </div>
- </div>
- </div>
- <script>
- $(function() {
- // a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
- $( "#dialog:ui-dialog" ).dialog( "destroy" );
-
- var firstName = $( "#firstName" ),
- lastName = $( "#lastName" ),
- emailAddress = $( "#emailAddress" ),
- eventId = $( "#eventId" ),
- allFields = $( [] ).add( firstName ).add( lastName ).add( emailAddress ).add( eventId ),
- tips = $( ".validateTips" );
- function updateTips( t ) {
- tips
- .text( t )
- .addClass( "ui-state-highlight" );
- setTimeout(function() {
- tips.removeClass( "ui-state-highlight", 1500 );
- }, 500 );
- }
- function checkLength( o, n, min, max ) {
- if ( o.val().length > max || o.val().length < min ) {
- o.addClass( "ui-state-error" );
- updateTips( "Length of " + n + " must be between " +
- min + " and " + max + "." );
- return false;
- } else {
- return true;
- }
- }
- function checkRegexp( o, regexp, n ) {
- if ( !( regexp.test( o.val() ) ) ) {
- o.addClass( "ui-state-error" );
- updateTips( n );
- return false;
- } else {
- return true;
- }
- }
-
- $( "#dialog-form" ).dialog({
- autoOpen: false,
- height: 425,
- width: 375,
- modal: true,
- buttons: {
- "Sign Up": function() {
- var bValid = true;
- allFields.removeClass( "ui-state-error" );
- bValid = bValid && checkLength( firstName, "firstName", 2, 40 );
- bValid = bValid && checkLength( lastName, "lastName", 2, 40 );
- bValid = bValid && checkLength( emailAddress, "emailAddress", 5, 60 );
- if ( bValid ) {
-
- $.ajax({
- type: "POST",
- url: "crud.php?act=create",
- data: "firstName=" + firstName.val() + "&lastName=" + lastName.val() + "&emailAddress=" + emailAddress.val() + "&eventId=" + eId,
- success: function(data){
-
- }
- });
-
- $( this ).dialog( "close" );
- }
- },
- Cancel: function() {
- $( this ).dialog( "close" );
- }
- },
- close: function() {
- allFields.val( "" ).removeClass( "ui-state-error" );
- }
- });
- $('#openMe').click(function() {
- $( "#dialog-form" ).dialog( "open" );
- consol.log();
- });
- });
- </script>
- </body>
- </html><?php
- mysql_free_result($eventImages);
- mysql_free_result($htmlcaption);
- ?>
Please any help would be great.