Can anybody teach me how to get the id of a data in a row then pass into the delete.php. i dont know how to do this., im very new to this.. tnx alot.
while($row = mysqli_fetch_assoc($result))
{
echo $row['id'];
echo " ";
echo $row['name'];
echo " ";
echo "<form id='form' action='delete.php'>";
echo "<input type='button' value='submit' id='btn".$row['id']."' name='but'>";
echo "<br>";
echo "
<script>
$('#btn".$row['id']."').click(function() {
alertify.confirm('Delete the selected entry?',function(e){
if(e) {
$('#form').submit();
return true;
} else {
return false;
}
});
});
</script>
";
}
echo "<form id='form' action='delete.php'>";
echo "<input type='hidden' name='delete' value='' $row['id']."' >";
echo "<input type='button' class='btn_del' >";
echo "<br>";
now in js
<script>
$('.btn").click(function() {
alertify.confirm('Delete the selected entry?',function(e){
if(e) {
$('#form').submit();
return true;
} else {
return false;
}
});
});
</script>
then get value in delete.php by
$is=$_REQUEST['delete'];
// your query here
while($row = mysqli_fetch_assoc($result))
{
echo $row['id'];
echo " ";
echo $row['name'];
echo " ";
echo "<form id='form' action='delete.php'>";
echo "<input type='hidden' name='rowid' value='".$row['id']."' >";
echo "<input type='button' value='submit' id='btn".$row['id']."'>";
echo "</form><br>";
echo "
<script>
$('#btn".$row['id']."').click(function() {
alertify.confirm('Delete the selected entry?',function(e){
if(e) {
$('#form').submit();
return true;
} else {
return false;
}
});
});
</script>
";
}
In delete.php
Use $_POST[rowid] to get the value of row id to be deleted.
Related
I'm trying to make a shopping page. I've kept checkboxes for selection and a number type field for quantity. As checkboxes are array I took the quantity field also an array... I know that we can check the checkbox state with checked method, now what I'm trying to achieve is to fetch corresponding quantity value and store it in a session varaible.
<?php
session_start();
if(isset($_POST['sub'])){
$_SESSION['cbb']=$_POST['cb'];
if(isset($_POST['qnty'])){
$_SESSION['qtty']=$_POST['qnty'];
header("location:userlogin.php");
}
}
?>
<html>
<head>
</head>
<body topmargin="20">
<font color='#7FFF00'>
<h1 align='center'>ONLINE SHOPPING</h1>
</font>
<form name="onshop" align="right" action="<?=$_SERVER["PHP_SELF"]?>"
method="post" onsubmit="return validate()">
<input type="submit" value="Add to cart" name="sub" style="background-
color:#7FFF00" />
<input type="reset" value="Reset" style="background-color:#7FFF00"/>
<?php
$db=mysqli_connect("localhost","root","","onlineshop");
if(!$db){
echo "Connection failure.";
}
$sql="SELECT * FROM stock";
$result=mysqli_query($db,$sql)or die("Invalid query ".mysqli_error($db));
echo "<TABLE width=50% height=70% align='center'>";
echo "<TR><TH>ITEM NAME</TH><TH>PRICE</TH><TH>IMAGE</TH><TH>Do you like?
</TH><TH>QUANTITY</TH></TR>";
while($myrow=mysqli_fetch_array($result))
{
echo "<TR><TD align='center'>";
echo $myrow["item"];
echo "</TD>";
echo "<TD align='center'>";
echo $myrow["price"];
echo "</TD>";
echo "<TD align='center'>";
$image=$myrow["image"];
echo '<img height="100" width="100" src="data:image/jpeg;base64,'.base64_encode( $image ).'"/>';
echo "</TD>";
echo "<TD align='center'>";
$itm_id=$myrow["id"];
echo "<input type='checkbox' name='cb[]' value='$itm_id'>";
echo "</TD>";
echo "<TD align='center'>";
echo "<input type='number' name='qnty[]' value='1' max='50'
min='1'>";
echo "</TD>";
echo "</TR>";
}
echo "</TABLE>";
mysqli_close($db);
?>
</form>
<script type="text/JavaScript">
function validate(){
var count=0;
var i;
var cbelements = document.getElementsByName("cb[]");
if(count==0){
for(i=0;i<cbelements.length;i++){
if(cbelements[i].checked){
count++;
}
}
if(count<1){
alert("Select atleast 1 item.");
return false;
}
}
}
</script>
</body>
</html>
Can the onchange event be useful in anyway? or the associative array ?
I want to pass this value doctoridclickedRightNow into t_appointmentdetails table. I have made few changes to previous code using AJAX and JS as suggested on How to Pass variable from JavaScript to PHP Page using XMLHTTP . Appointment details are getting inserted into DB and I also want the doctorid of the corresponding doctor to be saved. So with the below changes I am able see the correct values being displayed when I use inspect element in mozilla. Kindly suggest me how to pass this to DB. Thanks in advance.
$sql = "SELECT doctorid, FIRST_NAME,LAST_NAME, Address, Qualification, Specialization, Consultation_Fee, Experience,image_path
from t_doctorprofile";
$results = mysqli_query($db,$sql)
or die('MySQL Error');
echo '<h3 style="color:#674172;margin- left:120px;float:center;display:inline-block"><strong>Available Dentists</strong></h3>';
while($result = mysqli_fetch_assoc($results)){
echo '<div class= "fetch" style="margin-left:120px">';
echo "<img src = 'uploads/".$result['image_path']."' width='150' height='150'>";
echo "<div id='info'>";
echo "<p><strong>".$result['FIRST_NAME']." ".$result['LAST_NAME']."</strong></p></div>";
echo "<p>".$result['Qualification']."</p>";
echo "<p>".$result['Specialization']."</p>";
echo "<p>".$result['Address']."</p>";
echo "<p>"."<b>Consultation Fee-</b>"." ".$result['Consultation_Fee']."</p>";
echo "<p>"."<b>Experience-</b>"." ".$result['Experience']."years"." </p>";
echo "<button class='btn btn-success btn-lg' id='$result[doctorid]' data-toggle='modal' data-target='#myModal' onclick='AssignDoctorIdClicked(id)'>
Appointment</button>";
echo "<script>var doctoridclickedRightNow;</script>";
echo "</div>";
echo '<form action="appointment_insert.php" method="POST">';
echo "<div class='modal fade' id='myModal' tabindex='-1' role='dialog' aria-labelledby='myModalLabel' aria-hidden='true'>";
echo "<div class='modal-dialog'>";
echo "<div class='modal-content' style='background-color:#F1A9A0'>";
echo "<div class='modal-header'>";
echo "<button type='button' class='close' data-dismiss='modal' aria-hidden='true'>×</button>";
echo "<h4 class='modal-title' id='myModalLabel' style='text-align:center; color:#fff'>
<strong>Book Appointment</strong></h4><br>";
echo "</div><br><br>";
echo "<div class='modal-body'>";
script for AssignDoctorIdClicked function:
<script>
function AssignDoctorIdClicked(id) {
console.log(id);
var doctoridclickedRightNow = id;
console.log(doctoridclickedRightNow);
</script>
appointment_insert.php page
if (isset($_POST["submit"])) {
$login_user = $_SESSION['username'];
$datetime = $_POST['datetime'];
$info = $_POST['info'];
$recieved_1 = $_GET['FIRST_NAME'];
$query = mysqli_query($db, "INSERT INTO t_appointmentdetails (patient_name,datetime,info) VALUES ('$login_user','$datetime','$info');");
$insertedDataBoolean = true;
if($insertedDataBoolean){
echo "Name: " . $recieved_1 . " booked successfully.";
}
else{
echo "Data-insertion error.";
}
}
This is my first post here so I apologize in advance if the formatting is wrong.
I am working on a form that pulls data from MySQL using a loop and outputs it to HTML page. The user then has the option to approve or deny the entries, and based on user selection validation should be required or optional. My current code will validate correctly, but only for the first row being outputted from the loop. I am trying to validate all rows. I have tried using a while loop and foreach statement with no success. Any help would be greatly appreciated!
My Loop & Form:
//connect to the database
$db=mysqli_connect('localhost','root','') or die ('I cannot connect to the database because: ' . mysql_error());
//-select the database to use
$mydb=mysqli_select_db($db,"my_db") or die(mysql_error());
//-query the database table
$sql="SELECT id, date, client_name, client_number, date_completed, status FROM clients WHERE client_name LIKE '%" . $search ."%' OR status LIKE '%" . $search ."%' ";
//-run the query against the mysql query function
$result=mysqli_query($db, $sql);
//-count results
$rows=mysqli_num_rows($result);
if($rows=mysqli_num_rows($result)) {
echo "<h2 style='margin-left: 10em;margin-bottom: -0.4em;'><br><br><br>" . $rows . " result(s) found for " . $search . "</h2><br />";
}elseif($rows=mysqli_num_rows($result) == 0) {
echo "<h2 style='margin-left: 10em;margin-bottom: -0.4em;'><br><br><br>0 result(s) found for " . $search . "</h2><br />";
}
//-create while loop and loop through result set
while($row=mysqli_fetch_assoc($result)){
$id=$row['id'];
$date=$row['date'];
$client_name=$row['client_name'];
$client_number=$row['client_number'];
$date_completed=$row['date_completed'];
$status=$row['status'];
echo "<form method='post' enctype='multipart/form-data' action=''>";
echo "<table border='0'>";
echo "<tr>\n";
echo "<td>Timestamp</td><td>Client Name</td><td>Client Number</td>Status</td><td>Date Completed & Returned</td><td>Upload Zip Files</td>\n";
echo "</tr>";
echo "<tr>\n";
echo "<td readonly class='date'>$date</td>\n";
echo "<td><input readonly type='text' id='client_name' name='client_name' value='$client_name'></td>\n";
echo "<td><input readonly type='text' id='client_number' name='client_number' value='$client_number'></td>\n";
echo "<td><select id='status' name='status' aria-invalid='false'>
<option value=''>Select an option</option>
<option value='Denied'>Denied</option>
<option value='Approved'>Approved</option>
</select></td>\n";
echo "<td><input type='date' id='date_completed' name='date_completed_returned' value='$date_completed'></td>\n";
echo "<td><input type='file' id='upload' name='upload'></td>";
echo "<td class='submit'><input type='hidden' id='hidden' name='hidden' value='$client_name'><input type='submit' id='save' name='save' value='Save'></td>\n";
echo "</tr>";
echo "</table>";
echo "</form>";
}
My jQuery code:
I am trying to make date_completed and upload fields required if user selects "Approved" under status field, and optional if he selects "Denied".
<script>
$('#status').on('change', function() {
if ( this.value == 'Approved')
$("#date_completed").prop('required',true)
}).trigger("change"); // notice this line
$('#status').on('change', function() {
if ( this.value == 'Approved')
$("#upload").prop('required',true)
}).trigger("change"); // notice this line
</script>
Thanks to KevinB I was able to find a solution to my problem.
I added class names for the input fields (status, date_completed, upload) I was trying to validate:
Updated code below:
echo "<form method='post' enctype='multipart/form-data' action=''>";
echo "<table border='0'>";
echo "<tr>\n";
echo "<td>Timestamp</td><td>Client Name</td><td>Client Number</td>Status</td><td>Date Completed & Returned</td><td>Upload Zip Files</td>\n";
echo "</tr>";
echo "<tr>\n";
echo "<td readonly class='date'>$date</td>\n";
echo "<td><input readonly type='text' id='client_name' name='client_name' value='$client_name'></td>\n";
echo "<td><input readonly type='text' id='client_number' name='client_number' value='$client_number'></td>\n";
echo "<td><select id='status' name='status' class='status' aria-invalid='false'>
<option value=''>Select an option</option>
<option value='Denied'>Denied</option>
<option value='Approved'>Approved</option>
</select></td>\n";
echo "<td><input type='date' id='date_completed' name='date_completed' class='date_completed' value='$date_completed'></td>\n";
echo "<td><input type='file' id='upload' name='upload' class='upload'></td>";
echo "<td class='submit'><input type='hidden' id='hidden' name='hidden' value='$client_name'><input type='submit' id='save' name='save' value='Save'></td>\n";
echo "</tr>";
echo "</table>";
echo "</form>";
<script>
$('.status').on('change', function() {
if ( this.value == 'Approved')
$('.date_completed').prop('required',true)
}).trigger("change"); // notice this line
$('.status').on('change', function() {
if ( this.value == 'Approved')
$('.upload').prop('required',true)
}).trigger("change"); // notice this line
</script>
Hello guys i have a quiz system and i want that quiz will auto submit after the time is over this is my code but its not working.
<script type="text/javascript">
function countDown(secs, elem)
{
var element = document.getElementById(elem);
element.innerHTML = "<h2>You have <b>"+secs+"</b> seconds to answer the questions</h2>";
if(secs < 1) {
document.quiz.submit();
}
else
{
secs--;
setTimeout('countDown('+secs+',"'+elem+'")',1500);
}
}
function validate() {
return true;
}
</script>
<div id="status"></div>
<script type="text/javascript">countDown(4,"status");</script>
<title>Questionnaire</title>
<style type="text/css">
span {
color: #FF00CC;
}
</style>
<body>
<br />
<div class="col-sm-8">
<div class="panel panel-black">
<?php
include("db_conn.php");
$query="select * from question";
$rs=mysql_query("select * from question where test_id=$tid",$cn) or die(mysql_error());
if(!isset($_SESSION[qn]))
{
$_SESSION[qn]=0;
mysql_query("delete from useranswer where sess_id='" . session_id() ."'") or die(mysql_error());
$_SESSION[trueans]=0;
}
else
{
if($submit=='Next Question' && isset($ans))
{
mysql_data_seek($rs,$_SESSION[qn]);
$row= mysql_fetch_row($rs);
mysql_query("insert into useranswer(sess_id, test_id, que_des, ans1,ans2,ans3,ans4,true_ans,your_ans) values ('".session_id()."', $tid,'$row[2]','$row[3]','$row[4]','$row[5]', '$row[6]','$row[7]','$ans')") or die(mysql_error());
if($ans==$row[7])
{
$_SESSION[trueans]=$_SESSION[trueans]+1;
}
$_SESSION[qn]=$_SESSION[qn]+1;
}
else if($submit=='Get Result' && isset($ans))
{
mysql_data_seek($rs,$_SESSION[qn]);
$row= mysql_fetch_row($rs);
mysql_query("insert into useranswer(sess_id, test_id, que_des, ans1,ans2,ans3,ans4,true_ans,your_ans) values ('".session_id()."', $tid,'$row[2]','$row[3]','$row[4]','$row[5]', '$row[6]','$row[7]','$ans')") or die(mysql_error());
if($ans==$row[7])
{
$_SESSION[trueans]=$_SESSION[trueans]+1;
}
echo "<h1 class=head1> Result</h1>";
$_SESSION[qn]=$_SESSION[qn]+1;
echo "<Table align=center><tr class=tot><td>Total Question<td> $_SESSION[qn]";
echo "<tr class=tans><td>True Answer<td>".$_SESSION[trueans];
$w=$_SESSION[qn]-$_SESSION[trueans];
echo "<tr class=fans><td>Wrong Answer<td> ". $w;
echo "</table>";
mysql_query("insert into result(login,test_id,test_date,score) values('$login',$tid,'".date("d/m/Y")."',$_SESSION[trueans])") or die(mysql_error());
unset($_SESSION[qn]);
unset($_SESSION[sid]);
unset($_SESSION[tid]);
unset($_SESSION[trueans]);
exit;
}
}
$rs=mysql_query("select * from question where test_id=$tid",$cn) or die(mysql_error());
if($_SESSION[qn]>mysql_num_rows($rs)-1)
{
unset($_SESSION[qn]);
echo "<h1 class=head1>Some Error Occured</h1>";
session_destroy();
echo "Please <a href=test.php> Start Again</a>";
exit;
}
mysql_data_seek($rs,$_SESSION[qn]);
$row= mysql_fetch_row($rs);
echo "<form name=quiz method=post action=quiz.php onsubmit=return validate()>";
echo "<table width=100%> <tr> <td width=30> <td> <table border=0>";
$n=$_SESSION[qn]+1;
echo "<tR><td><span class=style2>Que ". $n .": $row[2]</style>";
echo "<tr><td class=style8><input type=radio name=ans value=1>$row[3]";
echo "<tr><td class=style8> <input type=radio name=ans value=2>$row[4]";
echo "<tr><td class=style8><input type=radio name=ans value=3>$row[5]";
echo "<tr><td class=style8><input type=radio name=ans value=4>$row[6]";
if($_SESSION[qn]<mysql_num_rows($rs)-1)
echo "<tr><td><input type=submit name=submit class='btn btn-lg btn-black' value='Next Question'></form>";
else
echo "<tr><td><input type=submit name=submit class='btn btn-lg btn-black' value='Get Result'></form>";
echo "</table></table>";
?>
</div>
</div>
This code i am using guys but problem is that the auto timer not submitting the quiz after over
Use setInterval instead of setTimeout. Because if you use setTimeout your countDown function will fire just one time.
setInterval(function() {
countDown(secs, elem)
},1500);
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.