<?php
$i=1;
//echo '<form id="form1" name="form1" method="post" action="<?PHP $_SERVER ['PHP_SELF' ]
echo '<form>';
echo "<select name='dropdown' id=$i onchange='myFunction()'><option>Select one...</option>";
echo '<option value="horse">horse</option>';
echo '<option value="hor">hor</option>';
echo '</select>';
echo '</form>';
$i++;
echo '<form>';
echo "<select name='dropdown' id=$i onchange='myFunction()'><option>Select one...</option>";
echo '<option value="por">por</option>';
echo '<option value="voi">voi</option>';
echo '</select>';
echo '</form>';
echo '<p id="demo"></p>
<script type ="text/javascript">
function myFunction()
{
var k=2;
var x=document.getElementById(k);
var y=x.options[x.selectedIndex];
if(y){
document.cookie=\'name=\'+y.value;
alert(y.value);
}
}
</script>';
$var=$_COOKIE["name"];
echo $var;
?>
Related
I have a JavaScript code which works with HTML select tag.
$(function() {
$('#to_name').on('change',function() {
if( $(this).val()=="<?php echo $ceo_chunks[0];?> <?php echo $ceo_chunks[1];?> <?php echo $ceo_chunks[2]?>") {
$('#to_designation').val('<?php echo $ceo_chunks[3];?>');
$('#dear_sir').val('<?php echo $ceo_chunks[0]?> <?php echo $ceo_last_name;?>') ;
if( $(this).val()=="<?php echo $liaison_one_chunks[0];?> <?php echo $liaison_one_chunks[1];?> <?php echo $liaison_one_chunks[2]?>") {
$('#to_designation').val('<?php echo $liaison_one_chunks[3]?>')
$('#dear_sir').val('<?php echo $liaison_one_chunks[0]?> <?php echo $liaison_one_last_name;?>')
$("#liaison_one").show()
$("#dear_liaison_one").show()
} else {
$("#ceo").hide()
$("#liaison_two").hide()
$("#dear_ceo").hide()
$("#dear_liaison_two").hide()
}
if( $(this).val()=="<?php echo $liaison_two_chunks[0];?> <?php echo $liaison_two_chunks[1];?> <?php echo $liaison_two_chunks[2]?>") {
$('#to_designation').val('<?php echo $liaison_two_chunks[3]?>')
$('#dear_sir').val('<?php echo $liaison_two_chunks[0]?> <?php echo $liaison_two_last_name;?>')
$("#liaison_two").show()
$("#dear_liaison_two").show()
} else {
$("#ceo").hide()
$("#liaison_one").hide()
$("#dear_ceo").hide()
$("#dear_liaison_one").hide()
}
};
});
});
and here is html code
<select name="to_name" id="to_name">
<option value="<?php echo $ceo_chunks[0];?> <?php echo $ceo_chunks[1];?> <?php echo $ceo_chunks[2]?>"><?php echo $ceo_chunks[0];?> <?php echo $ceo_chunks[1];?> <?php echo $ceo_chunks[2]?></option>
<option value="<?php echo $liaison_one_chunks[0];?> <?php echo $liaison_one_chunks[1];?> <?php echo $liaison_one_chunks[2]?>"><?php echo $liaison_one_chunks[0];?> <?php echo $liaison_one_chunks[1];?> <?php echo $liaison_one_chunks[2]?></option>
<option value="<?php echo $liaison_two_chunks[0];?> <?php echo $liaison_two_chunks[1];?> <?php echo $liaison_two_chunks[2]?>"><?php echo $liaison_two_chunks[0];?> <?php echo $liaison_two_chunks[1];?> <?php echo $liaison_two_chunks[2]?></option>
</select>
<br>
<select name="to_designation" id="to_designation">
<option value="<?php echo $ceo_chunks[3]?>" id="ceo"><?php echo $ceo_chunks[3]?></option>
<option value="<?php echo $liaison_one_chunks[3]?>" id="liaison_one"><?php echo $liaison_one_chunks[3]?></option>
<option value="<?php echo $liaison_two_chunks[3]?>"id="liaison_two"><?php echo $liaison_two_chunks[3]?></option>
</select>
<div id="dear_ceo" style="margin-top:10px; width:auto">
<input type="text" name="dear_sir" id="dear_ceo" value="Dear <?php echo $ceo_chunks[0]?> <?php echo $ceo_last_name;
?>"/>
</div>
<div id="dear_liaison_one" style="margin-top:10px; width:auto; display:none">
<input type="text" name="dear_sir" id="dear_liaison_one" value="Dear <?php echo $liaison_one_chunks[0]?> <?php echo $liaison_one_last_name;?>"/>
</div>
<div id="dear_liaison_two" style="margin-top:10px; width:auto; display:none">
<input type="text" name="dear_sir" id="dear_liaison_two" value="Dear <?php echo $liaison_two_chunks[0]?> <?php echo $liaison_two_last_name;?>"/>
</div>
My function works very well for select tag but it's not working with input type text.
How can I fix that?
There is a closing bracket clearly missing for your first if statement.
Please close the bracket. There is no logical error in your code.
$(function() {
$('#to_name').on('change',function(){
if( $(this).val()=="<?php echo $ceo_chunks[0];?> <?php echo $ceo_chunks[1];?> <?php echo $ceo_chunks[2]?>"){
$('#to_designation').val('<?php echo $ceo_chunks[3];?>')
$('#dear_sir').val('<?php echo $ceo_chunks[0]?> <?php echo $ceo_last_name;?>')
/*$("#ceo").show()
$("#dear_ceo").show()*/
//} ---uncomment this ---
also include a terminating semi-colon everytime you are calling a function. For example
if( $(this).val()=="<?php echo $ceo_chunks[0];?> <?php echo $ceo_chunks[1];?> <?php echo $ceo_chunks[2]?>"){
$('#to_designation').val('<?php echo $ceo_chunks[3];?>');
$('#dear_sir').val('<?php echo $ceo_chunks[0]?> <?php echo $ceo_last_name;?>');
}
I suggest you use semicolons at the end of line (when appropriate). I know they are not mandatory but consider them as a good practice.
You also have a semicolon at the end of if-clause at the end. It's probably not braking anything but just in case...
Try replacing spaces with underscores (_).
For example:
<?php echo $ceo_chunks[0];?> <?php echo $ceo_chunks[1];?> <?php echo $ceo_chunks[2]?>
would become
<?php echo $ceo_chunks[0];?>_<?php echo $ceo_chunks[1];?>_<?php echo $ceo_chunks[2]?>
And check if you can alert the value of the changed input correctly.
So I've been struggling with this for a while, i have a div and a form in a for each loop and on submitting one of the forms in the loop, the content of its div is updated in the database and refreshed ("div only"). This is done using JavaScript and Ajax. My update query works fine, JavaScript handles the form and Ajax refreshes only the div in the page. My problem is, upon refreshing all the contents in the loop are put into one div but instead i want one content to one div as many times the loop is run, to better understand my problem please refer to the image below:
Before:
After first like button is clicked:
This is the result i expect to see:
info.php
<html>
<head>
.......
<script type="text/javascript">
$(document).ready(function(){
$('.ajaxform').submit(function(e) {
e.preventDefault(); // catch the form's submit event
$.ajax({ // create an AJAX call...
data: $(this).serialize(), // get the form data
type: "POST", // POST
dataType:'html',
url: "test.php", // the file to call
cache: false,
success: function(response) { // on success..
$('.ld').html(response);
}
});
return false; // cancel original event to prevent form submitting
});
});
</script>
</head>
<body>
<?php
...........
foreach($stmt as $obj){
$username = $obj['user_name'];
$comment = $obj['comment'];
$id = $obj['id'];
$userimage = $obj['user_image'];
$row ++;
$likes = $obj['like1'];
$dislikes = $obj['dislike'];
echo '<div class="txt">';
echo '<div class="comment-container">';
echo '<div class="comment-item">';
echo '<div class="comment-avatar">';
echo '<img src="user/user_images/'.$userimage.'" alt="avatar">';
echo '</div>';
echo '<div class="comment-post">';
echo '<span style="font-weight:bold;">'.$username.'  said....
</span>';
echo '<p style="margin-left:-11px;">'.$comment.'</p>';
echo '<input type="hidden" name="comment_id" value="'.$id.'">';
echo '<form action="" method="post" class="ajaxform"
enctype="multipart/form-data">';//form to submit
echo '<input type="hidden" name="lkcv[]" value="'.$id.'">';
echo '<input type="hidden" name="pid" value="'.$type_id.'">';
echo '<input type="hidden" name="stk" value="'.$likes.'">';
echo '<input type="image" src="images/like.png" id="lksub" width="15"
value="som" height="15" style="float:right;position:relative;margin-
right:290px;"/><div class="ld">'.$likes.'</div>';//div to refresh
echo '</form>';
echo '<form action="" method="post" enctype="multipart/form-data">';
echo '<input type="hidden" name="lkd_id" value="'.$id.'">';
echo '<input type="hidden" name="dislike" value="">';
echo ' <input type= "image" id="submit" src="images/dislike.png"
width="15" height="15" style="float:right;position:relative;
margin-top:-14px;margin-right:230px;"/>
<div class="ldks">'.$dislikes.'</div>';
echo '</form>';
echo '<span class="SendCopy">Reply</span> ';
echo '<div class="users">';
echo '<form action="" method="post" enctype="multipart/form-
data">';
echo '<textarea rows="4" name="replycomment" style="float:right;
resize: none;margin-top:5px;" cols="50" >';
echo '</textarea>';
echo '<input type="hidden" name="comment_id" value="'.$id.'">';
echo '<input type="submit" name="reply" id="submit" class="post-
button" value="Send" />';
echo '</form>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
?>
</body>
</html>
test.php
<?php
$mysqli = new mysqli("localhost", "root", "", "Anonmy");
if( isset( $_POST['lkcv'] ) && is_array( $_POST['lkcv'] ) )
{
$idArray = array();
foreach( $_POST['lkcv'] as $value )
{
$idArray[] = intval( $value );
}
$mysqli->query( "UPDATE comment SET like1 = like1 + 1 WHERE id IN (".implode(
',', $idArray ).")" );
}
?>
<?php
$host = 'localhost';
$dbname = 'dbname';
$username = "root";
$password = "";
$conn = new PDO('mysql:host=localhost;dbname=Anonmy', $username,
$password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$type_id = $_POST['pid'];
$like = $_POST['stk'];
$target_no = 3;
echo '<div class="wrap">';
// retrive comments with post id
$stmt = $conn->prepare(
"SELECT *
FROM comment
WHERE post_id = :pid
");
$stmt->bindParam(":pid", $type_id, PDO::PARAM_INT);
$stmt->execute();
foreach($stmt as $obj){
$username = $obj['user_name'];
$comment = $obj['comment'];
$id = $obj['id'];
$userimage = $obj['user_image'];
$likes = $obj['like1'];
$dislikes = $obj['dislike'];
echo '<div class="">'.$likes.'</div>';
}
?>
</body>
</html>
How can i modify my code to achieve the result in image 3.
test.php[updated]
$host = 'localhost';
$dbname = 'dbname';
$username = "root";
$password = "";
$conn = new PDO('mysql:host=localhost;dbname=Anonmy', $username,
$password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$type_id = $_POST['pid'];
$like = $_POST['stk'];
$target_no = 3;
echo '<div class="wrap">';
// retrive comments with post id
$stmt = $conn->prepare(
"SELECT *
FROM comment
WHERE post_id = :pid
");
$stmt->bindParam(":pid", $type_id, PDO::PARAM_INT);
$stmt->execute();
//updated
$result = array();
foreach ($stmt as $row) {
$result[] = array('id' => $row['id'], 'likes' => $row['like1'], 'dislikes' =>
$row['dislike']);
}
echo json_encode($result);
?>
info.php[updated]
<html>
<head>
.......
<script type="text/javascript">
$(document).ready(function(){
$('.ajaxform').submit(function(e) {
e.preventDefault(); // catch the form's submit event
//updated
$.ajax({ // create an AJAX call...
data: $(this).serialize(), // get the form data
type: "POST", // POST
dataType:'json',
url: "test.php", // the file to call
cache: false, // Not needed for POST
success: function(response) { // on success..
$.each(response, function(i, el) {
var comment_post = $("#comment-post-" + el.id);
comment_post.find(".ld").text(el.likes);
comment_post.find(".ldks").text(el.dislikes);
});
}
});
return false; // cancel original event to prevent form submitting
});
});
</script>
</head>
<body>
<?php
...........
foreach($stmt as $obj){
$username = $obj['user_name'];
$comment = $obj['comment'];
$id = $obj['id'];
$userimage = $obj['user_image'];
$row ++;
$likes = $obj['like1'];
$dislikes = $obj['dislike'];
echo '<div class="txt">';
echo '<div class="comment-container">';
echo '<div class="comment-item">';
echo '<div class="comment-avatar">';
echo '<img src="user/user_images/'.$userimage.'" alt="avatar">';
echo '</div>';
echo '<div class="comment-post" id="comment-post-' . $id .'">';//updated
echo '<span style="font-weight:bold;">'.$username.'  said....
</span>';
echo '<p style="margin-left:-11px;">'.$comment.'</p>';
echo '<input type="hidden" name="comment_id" value="'.$id.'">';
echo '<form action="" method="post" class="ajaxform"
enctype="multipart/form-data">';//form to submit
echo '<input type="hidden" name="lkcv[]" value="'.$id.'">';
echo '<input type="hidden" name="pid" value="'.$type_id.'">';
echo '<input type="hidden" name="stk" value="'.$likes.'">';
echo '<input type="image" src="images/like.png" id="lksub" width="15"
value="som" height="15" style="float:right;position:relative;margin-
right:290px;"/><div class="ld">'.$likes.'</div>';//div to refresh
echo '</form>';
echo '<form action="" method="post" enctype="multipart/form-data">';
echo '<input type="hidden" name="lkd_id" value="'.$id.'">';
echo '<input type="hidden" name="dislike" value="">';
echo ' <input type= "image" id="submit" src="images/dislike.png"
width="15" height="15" style="float:right;position:relative;
margin-top:-14px;margin-right:230px;"/>
<div class="ldks">'.$dislikes.'</div>';
echo '</form>';
echo '<span class="SendCopy">Reply</span> ';
echo '<div class="users">';
echo '<form action="" method="post" enctype="multipart/form-
data">';
echo '<textarea rows="4" name="replycomment" style="float:right;
resize: none;margin-top:5px;" cols="50" >';
echo '</textarea>';
echo '<input type="hidden" name="comment_id" value="'.$id.'">';
echo '<input type="submit" name="reply" id="submit" class="post-
button" value="Send" />';
echo '</form>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
?>
</body>
</html>
test.php[ajax response]
<html>
<head>
<script type="text/javascript" src="js/jquery-2.1.4.js"></script>
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2
/jquery.min.js"> </script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1
/jquery.min.js"> </script>
<script language="JavaScript">
$(document).ready(function(){
$(".users").hide();
$(".SendCopy").click(function(){
$(this).next(".users").slideToggle("slow");
});
});
</script>
</head>
<body>
[{"id":"2","likes":"196","dislikes":"0"},
{"id":"5","likes":"80","dislikes":"0"},
{"id":"6","likes":"45","dislikes":"0"},
{"id":"7","likes":"31","dislikes":"0"}]
</body>
</html>
Change the HTML so that the post ID is included in the the ID of the DIV containing the like/dislike data.
echo '<div class="comment-post" id="comment-post-' . $id .'">';
Change test.php so it returns JSON instead of HTML:
$result = array();
foreach ($stmt as $row) {
$result[] = array('id' => $row['id'], 'likes' => $row['like1'], 'dislikes' => $row['dislike']);
}
echo json_encode($result);
Remove all other code in test.php that produces output, like this line:
echo '<div class="wrap">';
The only output should be the JSON.
Then in the AJAX call, extract the JSON data and update each corresponding element with its likes and dislikes.
$.ajax({ // create an AJAX call...
data: $(this).serialize(), // get the form data
type: "POST", // POST
dataType:'json',
url: "test.php", // the file to call
cache: false, // Not needed for POST
success: function(response) { // on success..
$.each(response, function(i, el) {
var comment_post = $("#comment-post-" + el.id);
comment_post.find(".ld").text(el.likes);
comment_post.find(".ldks").text(el.dislikes);
});
}
});
I am looking to add blog details to the following dropdown list to replace $site['domain'] in the option value with the detail 'blogname'. I also want to keep $site['domain'] in the option content.
function blavou_existing_sites() {
echo '<div id="blav-wrapper">';
echo '<div class="blav-nav-wrapper">';
echo '<ul class="blav-drop">';
echo '<form action="../">';
echo '<select name="mySelectbox" id="mySelectbox">';
echo '<option value="">Choose Existing</option>';
$sites = wp_get_sites();
foreach ($sites as $site) {
printf( '<option value="http://'.$site['domain'].'/wp-admin/">'.$site['domain'].'</option>');
}
echo '</select>';
echo '<input type="button" onclick="window.open(this.form.mySelectbox.options[this.form.mySelectbox.selectedIndex].value,\'_top\')" value="Confirm">';
echo '</form>';
echo '</ul>';
echo '</div>';
echo '</div>';
}
Help Appreciated!
You can use the get blog details() function:
foreach ($sites as $site) {
$details = get blog details($site['blog_id']);
printf( '<option value="%s">%s (%s)</option>', 'http://'.$site['domain'].'/wp-admin/', $details->blogname, $site['domain'] );
}
This should give you options like "blogname (url)".
How to pass the id (generated dynamically in while loop ) to jquery.
echo '<div><td><select name=categoryname id="name-first'.$i.'" >';
echo '</select></td>';
$(function(){
$('#name-first+<?php echo $i; ?>').on('change',function(){
var selIndex= $("#name-second+<?php echo $i; ?> option:selected").index();
$("#name-second+<?php echo $i; ?> option").eq(selIndex).prop('selected', true);
});
});
You have an extra + in there which is not there when you generate the id:
$('#name-first+<?php echo $i; ?>').on('change',function(){
should be
$('#name-first<?php echo $i; ?>').on('change',function(){
My form validation script seems to be running but the getElementById is only reading the first Id and skipping the rest for some reason. Is it due to closed tag issues? If so where do I put them? or is it another reason that I am overlooking somehow. Please help :(
I am thankful for any help, I've been staring at this for days. Here is the code.
The JS code.
<script type='text/javascript'>
function formValidator(){
// Make quick references to our fields
var name = document.getElementById('name');
var addr = document.getElementById('addr');
var phone = document.getElementById('phone');
var state = document.getElementById('state');
var username = document.getElementById('username');
var email = document.getElementById('email');
// Check each input in the order that it appears in the form!
if(isAlphabet(name, "Please enter only letters for your name")){
if(isAlphanumeric(addr, "Numbers and Letters Only for Address")){
if(isNumeric(phone, "Please enter only numeric values without any dashes")){
if(madeSelection(state, "Please Choose a State")){
if(lengthRestriction(username, 6, 8)){
if(emailValidator(email, "Please enter a valid email address")){
return true;
}
}
}
}
}
}
return false;
}
function notEmpty(elem, helperMsg){
if(elem.value.length == 0){
alert(helperMsg);
elem.focus(); // set the focus to this input
return false;
}
return true;
}
function isNumeric(elem, helperMsg){
var numericExpression = /^[0-9]+$/;
if(elem.value.match(numericExpression)){
return true;
}else{
alert(helperMsg);
elem.focus();
return false;
}
}
function isAlphabet(elem, helperMsg){
var alphaExp = /^[a-zA-Z]+$/;
if(elem.value.match(alphaExp)){
return true;
}else{
alert(helperMsg);
elem.focus();
return false;
}
}
function isAlphanumeric(elem, helperMsg){
var alphaExp = /^[0-9a-zA-Z]+$/;
if(elem.value.match(alphaExp)){
return true;
}else{
alert(helperMsg);
elem.focus();
return false;
}
}
function lengthRestriction(elem, min, max){
var uInput = elem.value;
if(uInput.length >= min && uInput.length <= max){
return true;
}else{
alert("Please enter between " +min+ " and " +max+ " characters");
elem.focus();
return false;
}
}
function madeSelection(elem, helperMsg){
if(elem.value == "Select State..."){
alert(helperMsg);
elem.focus();
return false;
}else{
return true;
}
}
function emailValidator(elem, helperMsg){
var emailExp = /^[\w\-\.\+]+\#[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
if(elem.value.match(emailExp)){
return true;
}else{
alert(helperMsg);
elem.focus();
return false;
}
}
</script>
Here is the form code.
<?php
// Will not show if submitted once so client cant resubmit over and over again.
if ($submitted==2)
{
echo "<h2>[ Return to main menu ]</h2>";
// sets variables to a Null string
$new_name='';
$new_phone='';
$new_email='';
$new_city='';
$new_state='';
$new_cost='';
$new_info ='';
}
else
{
echo "<div class=\"container\" >";
echo "<div class=\"form_container\" align=\"left\" >";
echo "<h2>Get Listed</h2>";
echo "<i>All required fields are marked with a red asteriks (<font color=\"red\"> * </font>)</i><br/><br/>";
echo "<form action=\"#\" onsubmit=\"return formValidator()\" method=\"post\" >";
echo "<font color=\"red\">*</font> <input type=\"checkbox\" name=\"terms\" value=\"yes\" >
Yes, I agree to our <a href=\"../legal/index.php\" target=\"_blank\" >
<i>Terms and Conditions</i></a><br/><br/>";
echo "<h2>Limo Service Details</h2>";
echo "<font color=\"red\"/>*</font> Service Name: <br/>";
echo "<input type=\"text\" name=\"in_name\" maxlength=\"60\" size=\"26\" id=\"name\" value='$new_name' >";
echo "<br/>";
echo "<font color=\"red\"/>*</font> Phone: <br/>";
echo "<input type=\"text\" name=\"in_phone\" maxlength=\"60\" size=\"26\" id=\"phone\" value='$new_phone' >";
echo "<br/>";
echo "<font color=\"red\"/>*</font> Email: <br/>";
echo "<input type=\"text\" name=\"in_email\" maxlength=\"60\" size=\"26\" id=\"email\" value='$new_email' >";
echo "<br/>";
echo "<font color=\"red\">*</font> Cost: <br/>";
echo "<input type=\"text\" name=\"in_cost\" maxlength=\"30\" size=\"11\" value='$new_cost' >";
echo " ";
echo "<select style=\"width: 120px\" name=\"in_rate\" >";
echo "<option value=\"daily\" selected>Daily</option>";
echo "<option value=\"hourly\">Hourly</option>";
echo "</select>";
echo "<br/>";
echo "<font color=\"red\">*</font> City: <select name=\"in_city\" style=\"width: 245px\" >";
echo "<option value=\"\">Select City...</option>";
echo "<option value=\"Atlanta\">Atlanta</option>";
echo "<option value=\"Atlantic City\">Atlantic City</option>";
echo "<option value=\"Austin\">Austin</option>";
echo "<option value=\"Baltimore\">Baltimore</option>";
echo "<option value=\"Boston\">Boston</option>";
echo "<option value=\"Charlotte\">Charlotte</option>";
echo "<option value=\"Chicago\">Chicago</option>";
echo "<option value=\"Cincinnati\">Cincinnati</option>";
echo "<option value=\"Columbus\">Columbus</option>";
echo "<option value=\"Dallas\">Dallas</option>";
echo "<option value=\"Denver\">Denver</option>";
echo "<option value=\"Detroit\">Detroit</option>";
echo "<option value=\"Fort Lauderdale\">Fort Lauderdale</option>";
echo "<option value=\"Honolulu\">Honolulu</option>";
echo "<option value=\"Houston\">Houston</option>";
echo "<option value=\"Indianapolis\">Indianapolis</option>";
echo "<option value=\"Irvine\">Irvine</option>";
echo "<option value=\"Las Vegas\">Las Vegas</option>";
echo "<option value=\"Los Angeles\">Los Angeles</option>";
echo "<option value=\"Miami\">Miami</option>";
echo "<option value=\"Minneapolis\">Minneapolis</option>";
echo "<option value=\"Nashville\">Nashville</option>";
echo "<option value=\"Newark\">Newark</option>";
echo "<option value=\"New York\">New York</option>";
echo "<option value=\"Oklahoma\">Oklahoma City</option>";
echo "<option value=\"Orlando\">Orlando</option>";
echo "<option value=\"Portland\">Portland</option>";
echo "<option value=\"Philadelphia\">Philadelphia</option>";
echo "<option value=\"Phoenix\">Phoenix</option>";
echo "<option value=\"Raleigh\">Raleigh</option>";
echo "<option value=\"Sacramento\">Sacramento</option>";
echo "<option value=\"Salt Lake City\">Salt Lake City</option>";
echo "<option value=\"San Antonio\">San Antonio</option>";
echo "<option value=\"San Diego\">San Diego</option>";
echo "<option value=\"San Francisco\">San Francisco</option>";
echo "<option value=\"Tampa\">Tampa</option>";
echo "</select>";
echo "<br/>";
// City2
echo " City 2: <select name=\"in_city2\" style=\"width: 245px\" >";
echo "<option value=\"\">Select City...</option>";
echo "<option value=\"Atlanta\">Atlanta</option>";
echo "<option value=\"Atlantic City\">Atlantic City</option>";
echo "<option value=\"Austin\">Austin</option>";
echo "<option value=\"Baltimore\">Baltimore</option>";
echo "<option value=\"Boston\">Boston</option>";
echo "<option value=\"Charlotte\">Charlotte</option>";
echo "<option value=\"Chicago\">Chicago</option>";
echo "<option value=\"Cincinnati\">Cincinnati</option>";
echo "<option value=\"Columbus\">Columbus</option>";
echo "<option value=\"Dallas\">Dallas</option>";
echo "<option value=\"Denver\">Denver</option>";
echo "<option value=\"Detroit\">Detroit</option>";
echo "<option value=\"Fort Lauderdale\">Fort Lauderdale</option>";
echo "<option value=\"Honolulu\">Honolulu</option>";
echo "<option value=\"Houston\">Houston</option>";
echo "<option value=\"Indianapolis\">Indianapolis</option>";
echo "<option value=\"Irvine\">Irvine</option>";
echo "<option value=\"Las Vegas\">Las Vegas</option>";
echo "<option value=\"Los Angeles\">Los Angeles</option>";
echo "<option value=\"Miami\">Miami</option>";
echo "<option value=\"Minneapolis\">Minneapolis</option>";
echo "<option value=\"Nashville\">Nashville</option>";
echo "<option value=\"Newark\">Newark</option>";
echo "<option value=\"New York\">New York</option>";
echo "<option value=\"Oklahoma\">Oklahoma City</option>";
echo "<option value=\"Orlando\">Orlando</option>";
echo "<option value=\"Portland\">Portland</option>";
echo "<option value=\"Philadelphia\">Philadelphia</option>";
echo "<option value=\"Phoenix\">Phoenix</option>";
echo "<option value=\"Raleigh\">Raleigh</option>";
echo "<option value=\"Sacramento\">Sacramento</option>";
echo "<option value=\"Salt Lake City\">Salt Lake City</option>";
echo "<option value=\"San Antonio\">San Antonio</option>";
echo "<option value=\"San Diego\">San Diego</option>";
echo "<option value=\"San Francisco\">San Francisco</option>";
echo "<option value=\"Tampa\">Tampa</option>";
echo "</select>";
echo "<br/>";
// City3
echo " City 3: <select name=\"in_city3\" style=\"width: 245px\" >";
echo "<option value=\"\">Select City...</option>";
echo "<option value=\"Atlanta\">Atlanta</option>";
echo "<option value=\"Atlantic City\">Atlantic City</option>";
echo "<option value=\"Austin\">Austin</option>";
echo "<option value=\"Baltimore\">Baltimore</option>";
echo "<option value=\"Boston\">Boston</option>";
echo "<option value=\"Charlotte\">Charlotte</option>";
echo "<option value=\"Chicago\">Chicago</option>";
echo "<option value=\"Cincinnati\">Cincinnati</option>";
echo "<option value=\"Columbus\">Columbus</option>";
echo "<option value=\"Dallas\">Dallas</option>";
echo "<option value=\"Denver\">Denver</option>";
echo "<option value=\"Detroit\">Detroit</option>";
echo "<option value=\"Fort Lauderdale\">Fort Lauderdale</option>";
echo "<option value=\"Honolulu\">Honolulu</option>";
echo "<option value=\"Houston\">Houston</option>";
echo "<option value=\"Indianapolis\">Indianapolis</option>";
echo "<option value=\"Irvine\">Irvine</option>";
echo "<option value=\"Las Vegas\">Las Vegas</option>";
echo "<option value=\"Los Angeles\">Los Angeles</option>";
echo "<option value=\"Miami\">Miami</option>";
echo "<option value=\"Minneapolis\">Minneapolis</option>";
echo "<option value=\"Nashville\">Nashville</option>";
echo "<option value=\"Newark\">Newark</option>";
echo "<option value=\"New York\">New York</option>";
echo "<option value=\"Oklahoma\">Oklahoma City</option>";
echo "<option value=\"Orlando\">Orlando</option>";
echo "<option value=\"Portland\">Portland</option>";
echo "<option value=\"Philadelphia\">Philadelphia</option>";
echo "<option value=\"Phoenix\">Phoenix</option>";
echo "<option value=\"Raleigh\">Raleigh</option>";
echo "<option value=\"Sacramento\">Sacramento</option>";
echo "<option value=\"Salt Lake City\">Salt Lake City</option>";
echo "<option value=\"San Antonio\">San Antonio</option>";
echo "<option value=\"San Diego\">San Diego</option>";
echo "<option value=\"San Francisco\">San Francisco</option>";
echo "<option value=\"Tampa\">Tampa</option>";
echo "</select>";
echo "<br/>";
// State
echo "<font color=\"red\">*</font> State: <select name=\"in_state\" id=\"state\" style=\"width: 245px\" >";
echo "<option>Select State...</option>";
echo "<option value=\"Alabama\">Alabama</option>";
echo "<option value=\"Alaska\">Alaska</option>";
echo "<option value=\"Arizona\">Arizona</option>";
echo "<option value=\"Arkansas\">Arkansas</option>";
echo "<option value=\"California\">California</option>";
echo "<option value=\"Colorado\">Colorado</option>";
echo "<option value=\"Connecticut\">Connecticut</option>";
echo "<option value=\"Delaware\">Delaware</option>";
echo "<option value=\"Florida\">Florida</option>";
echo "<option value=\"Georgia\">Georgia</option>";
echo "<option value=\"Hawaii\">Hawaii</option>";
echo "<option value=\"Idaho\">Idaho</option>";
echo "<option value=\"Illinois\">Illinois</option>";
echo "<option value=\"Indiana\">Indiana</option>";
echo "<option value=\"Iowa\">Iowa</option>";
echo "<option value=\"Kansas\">Kansas</option>";
echo "<option value=\"Kentucky\">Kentucky</option>";
echo "<option value=\"Louisiana\">Louisiana</option>";
echo "<option value=\"Maine\">Maine</option>";
echo "<option value=\"Maryland\">Maryland</option>";
echo "<option value=\"Massachusetts\">Massachusetts</option>";
echo "<option value=\"Michigan\">Michigan</option>";
echo "<option value=\"Minnesota\">Minnesota</option>";
echo "<option value=\"Mississippi\">Mississippi</option>";
echo "<option value=\"Missouri\">Missouri</option>";
echo "<option value=\"Montana\">Montana</option>";
echo "<option value=\"Nebraska\">Nebraska</option>";
echo "<option value=\"Nevada\">Nevada</option>";
echo "<option value=\"New Hampshire\">New Hampshire</option>";
echo "<option value=\"New Jersey\">New Jersey</option>";
echo "<option value=\"New Mexico\">New Mexico</option>";
echo "<option value=\"New York\">New York</option>";
echo "<option value=\"North Carolina\">North Carolina</option>";
echo "<option value=\"North Dakota\">North Dakota</option>";
echo "<option value=\"Ohio\">Ohio</option>";
echo "<option value=\"Oklahoma\">Oklahoma</option>";
echo "<option value=\"Oregon\">Oregon</option>";
echo "<option value=\"Pennsylvania\">Pennsylvania</option>";
echo "<option value=\"Rhode Island\">Rhode Island</option>";
echo "<option value=\"South Carolina\">South Carolina</option>";
echo "<option value=\"South Dakota\">South Dakota</option>";
echo "<option value=\"Tennessee\">Tennessee</option>";
echo "<option value=\"Texas\">Texas</option>";
echo "<option value=\"Utah\">Utah</option>";
echo "<option value=\"Vermont\">Vermont</option>";
echo "<option value=\"Virginia\">Virginia</option>";
echo "<option value=\"Washington\">Washington</option>";
echo "<option value=\"West Virginia\">West Virginia</option>";
echo "<option value=\"Wisconsin\">Wisconsin</option>";
echo "<option value=\"Wyoming\">Wyoming</option>";
echo "</select>";
echo "<br/><br/>";
//Additional Info
echo " Additional Info: ";
echo "<br/>";
echo "<textarea rows=\"5\" cols=\"26\" name=\"in_info\" >$new_info";
echo "</textarea>";
echo "<font size=\"1\"> (Maximum characters: 500)</font>";
echo "<br/>";
//Submit Button
echo "<input type=\"hidden\" name=\"submission\" value=\"1\">";
echo "<center><input type=\"submit\" value=\"LIST ME\" class=\"button2\" /></center>";
echo "</form>";
echo "</div>";
echo "</div>";
}
?>
Once validated it gets sent to a php mysql file that inputs it into my database. Thanks again for any help.
~Nikoli
Your code is not doing what you think it is.
var name = document.getElementById('name');
returns:
<input type="text" name="in_name" maxlength="60" size="26" id="name" value='$new_name' >
Instead, to get the value, you want to do:
var name = document.getElementById('name').value;
That should solve your current problem.
On another note, you should probably look into closing that php tag instead of wrapping everything in echo statements. Using CSS for your styles will save you a lot of headache in the future as well.