Web Design and Development Forums

Appending Text Javascript

This is a discussion on "Appending Text Javascript" within the JavaScript Forum section. This forum, and the thread "Appending Text Javascript are both part of the Program Your Website category.

Old Apr 28th, 2008, 04:34   #1 (permalink)
New Member
 
Join Date: Apr 2008
Location: Connecticut
Posts: 1
Appending Text Javascript

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.
Code: Select all
<?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> &nbsp;&nbsp;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, &amp; 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>&nbsp;</p>
                                                <p>&nbsp;</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


Last edited by CloudedVision; Apr 28th, 2008 at 12:13. Reason: use [CODE] tags and no signiture until after 25 posts
Utite is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Apr 28th, 2008, 12:14   #2 (permalink)
Nerdy Moderator
 
CloudedVision's Avatar
 
Join Date: Feb 2008
Location: In My Own Little World
Age: 14
Posts: 520
Blog Entries: 4
Re: Appending Text Javascript

Think you could just give us the code that we need to know? Nobodies gonna want to read through that entire script.
__________________
Take it easy

Other Road Design

WebForumz Moderator: HTML | Javascript | PHP
CloudedVision is online now  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript -> text include <- help jahphill JavaScript Forum 3 Oct 30th, 2007 22:06
BBC Text Editor With Javascript AdRock JavaScript Forum 2 Oct 17th, 2007 15:10
appending vars moiseszaragoza Flash & Multimedia Forum 1 Apr 5th, 2007 03:42
asp:Label text in javascript QuikFrozen ASP.NET Forum 1 Aug 17th, 2006 13:11
Appending multiple records jakyra ASP Forum 0 Sep 8th, 2003 19:33



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 20:11.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59