UTITE Posted April 28, 2008 Share Posted April 28, 2008 Hi all, I have a simple problem, but I can't seem to figure this out for the life of me. Problem: 1. Using Javascript and PHP 2. Move values from onClick links to text boxes 3. Want to call the function (superpaste) to create a custom sql statement. Every thing works other than the calling of the superpaste function and its workings. <?php //require_once('adminOnly.php'); if(file_exists("util.php")) { require_once("util.php"); // use the predefined database parameter constants $dbname = DBNAME; }elseif (file_exists("configure.php")) { require_once("configure.php"); // use the predefined database parameter constants $dbname = DBNAME; }elseif (file_exists("mysetup.php")) { require_once("mysetup.php"); // use the predefined database parameter constants $dbname = DBNAME; /////////////////////////////////////////////////////////////////////////////////// ////////////////////////// SET YOUR DB CONNECT VALUES BELOW HERE ///////////////////////////// }else{ // if not using CONSTANTS then set your unique database connectivity values below $dbname = !isset($dbname)?"xxxxxx":$_POST['dbname']; $dbserverhost = !isset($dbserverhost)?"xxxx":$_POST['dbserverhost']; $dbusername = !isset($dbusername)?"xxxxx":$_POST['dbusername']; $dbpassword = !isset($dbpassword)?"xxxxx":$_POST['dbpassword']; } /////////////////////////////////////////////////////////////////////////////////// ////////////////////////// SET YOUR DB CONNECT VALUES ABOVE HERE ///////////////////////////// $modifiedColor = "orange"; // initialize or capture variable values $query = !isset($_POST['query'])?"SHOW TABLES":$_POST['query']; $showLastQuery = !isset($_POST['showLastQuery'])?NULL:$_POST['showLastQuery']; $showSyntax = !isset($_POST['showSyntax'])?NULL:$_POST['showSyntax']; $myStatus = !isset($_REQUEST['myStatus'])?NULL:$_REQUEST['myStatus']; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>Recruiting @ UTITE</TITLE> <!-- START OF JAVASCRIPT FUNCTIONS FOR ALL easysql.php RELEASES --> <script language="JavaScript" type="text/javascript"> <!-- /* paste text into the query box */ /////////////////////////////////////////////////////////////////////////////////////// function superpaste(){ var writingblock = document.myQueryForm.query; var degree = document.first_form.degree.value; var interest = document.first_form.interest.value; var region = document.first_form.region.value; var experience = document.first_form.experience.value; var writingblock.value = "Select * from Resume WHERE degree_program = '"; var writingblock.value =+ degree; var writingblock.value =+ "' AND interest = '"; var writingblock.value =+ interest; var writingblock.value =+ "' AND region ='"; var writingblock.value =+ region; var writingblock.value =+ " ' AND experience = '"; var writingblock.value =+ experience; var writingblock.value =+ "' ;"; } } ////////////////////////////////////////////////////////////////////////////////// /* This function tests to see if something has been entered in the query. If empty then an alert box appears and the form submission is halted */ function isQuery() { var myForm = document.myQueryForm; if ( myForm.query.value == 0 ) { alert("There is no query.\nPlease enter a query."); myForm.query.focus(); return false; } return true; } // --> </script> <!-- END OF JAVASCRIPT FUNCTIONS FOR ALL easysql.php RELEASES --> <META name="ROBOTS" content="NOINDEX,NOFOLLOW"> <style type="text/css"> <!-- .style1 { color: #CC5500; font-weight: bold; } --> </style> </HEAD> <BODY> <td align="left"><p class="style1">Candidate Profile Builder:</p> <p><strong>Degree:</strong><br> <a href="#" onClick="document.first_form.degree.value='Undergraduate';">Undergraduate</a> <a href="#" onClick="document.first_form.degree.value='MBA';">MBA</a> <a href="#" onClick="document.first_form.degree.value='PhD';">Ph D</a> <p><strong>Looking For:</strong><br> <a href="#" onClick="document.first_form.interest.value='Internship';">Internship</a> <a href="#" onClick="document.first_form.interest.value='Part Time';">Part Time</a> <a href="#" onClick="document.first_form.interest.value='Full Time';">Full Time</a> <br> </p> <p><strong>Where</strong>:<br> <a href="#" onClick="document.first_form.region.value='Texas';">Texas and Surrounding Area</a> <a href="#" onClick="document.first_form.region.value='North';">North</a> <a href="#" onClick="document.first_form.region.value='South';">South</a> <a href="#" onClick="document.first_form.region.value='West';">West</a> <a href="#" onClick="document.first_form.experience.value='East';">East</a> <p><strong>Relevant Work Experience:</strong><br> <a href="#" onClick="document.first_form.region.value='<=1';">1 or Less</a> <a href="#" onClick="document.first_form.experience.value='<=2 AND >= 1';">1-2 Years</a> <a href="#" onClick="document.first_form.experience.value='>=2';">2+ Years</a> <a href="#" onClick="superpaste()">YES</a> <p><strong>My Candidate: </strong> <form name="first_form"> <input name="degree" type="text" id="degree"> <input name="interest" type="text" id="interest"> <input name="region" type="text" id="region"> <input name="experience" type="text" id="experience"> </form> <blockquote> <?php // this block below captures defined CONSTANTS, if they are used via an include call if(defined('DBSERVERHOST')) { $dbserverhost = DBSERVERHOST; // if CONSTANTS are used then set the variable value } if(defined('DBUSERNAME')) { $dbusername = DBUSERNAME; // if CONSTANTS are used then set the variable value } if(defined('DBPASSWORD')) { $dbpassword = DBPASSWORD; // if CONSTANTS are used then set the variable value } // this block above captures defined CONSTANTS, if they are used via an include call if (!empty($dbserverhost)) { $rowsModified = 0; $rowsSelected = 0; // pconnect, select and query if ($link_identifier = mysql_pconnect($dbserverhost, $dbusername, $dbpassword)) { if ( mysql_select_db($dbname, $link_identifier)) { if((!isset($query)) || empty($query)) { echo"<br><b>EasySQL</b> Enter your query into the textarea box then click on <b>RUN MY QUERY</b><br>"; }else{ $query = stripslashes($query); $result = mysql_query($query, $link_identifier); $partialCommand = ltrim($query); // strip leading characters eg. spaces $partialCommand = substr ( $partialCommand, 0, 4); /* get first 4 characters for switch()*/ $partialCommand = strtolower($partialCommand); switch($partialCommand) { /* the first 4 letters from each sql statement are used for this switch */ case "alte": // zero to nn records are affected with Alter table case "dele": // zero to nn records are affected with Delete case "inse": // zero to 1 record affected with Insert case "upda": // zero to nn records are affected with Update if ($result != 0) { $rowsModified = mysql_affected_rows($link_identifier); $myStatus = "SQL was processed"; }else{ echo("Error " . mysql_errno() . ": " . mysql_error() . "<br>"); } break; case "sele": // zero to nn rows returned if ($result != 0) { $rowsSelected = mysql_num_rows($result); $myStatus = "SQL was processed"; }else{ echo("Error " . mysql_errno() . ": " . mysql_error() . "<br>"); } break; /* no affected records */ case "crea": // no records affected case "desc": case "drop": case "load": case "show": $rowsModified = 0; $myStatus = "SQL was processed"; break; default: $myStatus = "ALTER, DELETE, UPDATE, INSERT, CREATE, DESCRIBE, DROP, LOAD, SHOW, & SELECT are the SQL commands currently supported in EasySQL.<br>\n"; } // switch($partialCommand) // display results of the submitted query echo"<b>Query:</b> $query<br>\n"; echo"<b>Result:</b> $myStatus<br>\n"; echo"<b>Rows: </b> "; if ($partialCommand == "sele") { echo"$rowsSelected selected<p></p>"; }else{ echo "<b><font color=\"$modifiedColor\">$rowsModified modified</font></b><p></p>\n"; } if (@mysql_num_rows($result) != 0){ // if there are rows then show them echo"<TABLE BORDER=1><TR>\n"; for ($i = 0; $i < mysql_num_fields($result); $i++) { echo("<TH>" . mysql_field_name($result,$i) . "</TH>"); } echo"</TR>\n"; for ($i = 0; $i < mysql_num_rows($result); $i++) { echo("<TR>\n"); $row_array = mysql_fetch_row($result); for ($j = 0; $j < mysql_num_fields($result); $j++) { echo("<TD>" . $row_array[$j] . "</TD>\n"); } echo("</TR>\n"); } echo"</TABLE>"; }else{ //echo"No matches."; } } // if(!isset($query)) ?> <!-- START OF table to encompass the entire SQL Command entry form --> <br> <table cellpadding="5" align="left" border="10"> <tr> <td> <form method="post" name="myQueryForm" action="easysql.php" onSubmit="isQuery()"> <textarea style="background-color:honeydew;" name="query" cols=80 rows=8 wrap="soft"><?php if ($showLastQuery == "reuse"){echo"$query";}?></textarea><br> <!-- ******* START OF STANDARD easysql CONTROLS ******* --> <table width="100%"> <tr> <td align="right"> <!-- begin code to retrieve available database names --> <?php $db_list = mysql_list_dbs(); $i = 0; $count = mysql_num_rows($db_list); if( $count > 0 ) { // if there are 1 or more databases found // build a select list echo"<select name='dbname'>\n"; // begin the select list echo "<option value='$dbname' SELECTED>$dbname</option>\n"; while ($i < $count) { $option = mysql_db_name($db_list, $i); // set the unique value echo "<option value='$option'>$option</option>\n"; $i++; } echo"</select>\n"; }else{ echo"No databases found."; } ?> <!-- end of code to retrieve available database names --> <input style="color:white;font-weight:bold;background-color:green;" type="submit" name="submit" value="RUN MY QUERY" class="submit"> </td> </tr> <tr> <?php if($showSyntax == 'on'):?> </p> <p> <label></label> </p> <p> </p> <p> </p> <font size="2"> <p></p> </font> <?php endif;?> <!-- END OF table for standard easysql controls --></td></tr></table> <!-- ******* END OF STANDARD CONTROLS ******* --> <!-- This is part of the regular distribution package --> </form> </td></tr></table> <!-- END OF table to encompass the entire SQL Command entry form --> <?php }else{ // in NO select db echo mysql_error(); } }else{ // if no connect echo mysql_error(); } } // if DBSERVERHOST ?> </blockquote> </BODY> </HTML> THANKS ALL http://utite.org/resumeinfo/easysql.php# Link to comment https://forums.phpfreaks.com/topic/103221-append-text-javascript/ Share on other sites More sharing options...
Psycho Posted April 29, 2008 Share Posted April 29, 2008 Use += not =+ Link to comment https://forums.phpfreaks.com/topic/103221-append-text-javascript/#findComment-529350 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.