hielo 65 Veteran Poster

try:

<?php

$connect = mysql_connect("localhost","root","") or die ("connection failed!");
mysql_select_db("users") or die (mysql_error());


echo "connected!"

$recordset = mysql_query("select * from member order by id ASC") or die( mysql_error());
$row=mysql_fetch_assoc($recordset);
extract( $row );



?>
hielo 65 Veteran Poster

To understand that, you need to realize that your doSearch() has the following: window.location.href = submitto; That line basically will change the browser's url to whatever is in the submitto variable. Essentially that line is emitting a search request using method="get" , since all the search parameters are already included in the submitto variable.

If you were to REMOVE that line and get rid of return false, then you would notice that the same thing happens - meaning, the url changes so that it contains all the search parameters. Since you do NOT have <form method='post'...> , the browser defaults to <form method='get'...> . This is the reason why the url would change and include the search parameters if you were to get rid of return false; and the [ window.location.href = submitto; So, to summarize, if you get rid of return false; , the browser would submit the FORM 's search request using method="get" and by having window.location.href = submitto; it would ALSO submit a search request using method="get" .

Clearly, there is NO need to submit two requests for every search you make. So, by adding return false, the FORM 's get request is cancelled.

hielo 65 Veteran Poster

detached_fields += $(this).remove();

that's your problem. You can concatenate STRINGS, but NOT objects. remove() returns an object. Since you are issuing a concatenation operator, javascript calls its toString() method which simply returns a string whose value is [object Object] . What you need is the ACTUAL objects. Make detached_fields an array, and then as you remove an item add/push it to that array. In your else clause, you need to iterate over the array, popping one item at a time. As you pop each item, add it back to your form.

hielo 65 Veteran Poster

try:

<?xml version="1.0" encoding="ISO-8859-1"?>
<internal_guides>
<% While (Not guides.EOF) %>
	<guide>
		<id><![CDATA[<%=(guides.Fields.Item("ID").Value)%>]]></id>
		<title><![CDATA[<%=(guides.Fields.Item("Title").Value)%>]]></title>
		<%
		If NOT steps.EOF Then
			steps.moveFirst()
			While (NOT steps.EOF) 
				If (steps.Fields.Item("GuideID").Value) = (guides.Fields.Item("ID").Value) Then
				%>
					<step><![CDATA[<%=(steps.Fields.Item("Info").Value)%>]]></step>
				<%
				End If
				steps.moveNext()
			Wend
		End If
%>
	</guide>
<% 
	guides.MoveNext()
Wend 
%>
</internal_guides>
<%
guides.Close()
Set guides= Nothing

steps.Close()
Set steps = Nothing
%>
hielo 65 Veteran Poster
what happens now its that if you lick on a link than the url at the top wont change

Yes, that was expected. Why is that an issue? Aren't you tracking the last hash in a variable? Meaning, everytime a link with a hash is clicked you are updating lasturl . If later on I click on a different link that has a hash, then you need to compare the hash on the "current link that was just clicked" against what you previously stored in lasturl . IF they match, then don't do an ajax request (since it is already loaded - should be the current loaded page).

hielo 65 Veteran Poster

I never worked with PHP before though, and the question is how are the vars in URLs called?

When someone visits your page and the url to your page contains variables like site.com/test.php?f=17&s=23 , the PHP engine automatically creates a global array named $_GET which gets "stuffed" with the url parameters. Thus, given the sample url above you can see the values by echoing them as follows:

echo $_GET['f'];
echo $_GET['s'];

You can of course simply assign those values to some other variable: $F=$_GET['f']; and then do whatever you want/need with $F On the other hand, if you have a string that is formatted like a URL, you can use parse_str() (http://us.php.net/manual/en/function.parse-str.php) to "extract" the parameters in the url yourself - basically doing exactly what the PHP engine does automatically when initializing $_GET :

$str="site.com/test.php?f=17&s=23";
parse_str($str,$param);

echo $param['f'];
echo $param['s'];
hielo 65 Veteran Poster

try returning false so that the browser does not navigate away when the link is clicked:

$('ul li a').click(function (e){

			checkURL(this.hash);
          return false;
	});
hielo 65 Veteran Poster

because if your script is sending Hello{"title":"test"} , only {"title":"test"} is a JSON string. Read about JSON on the json.org website.

To clarify further, if you are familiar with xml, you would know that this IS Valid XML:

<root>
 <title>Test</title>
</root>

but NOT this:

Hello
<root>
 <title>Test</title>
</root>

The same concept applies to what you are sending. By introducing the "BaSk" delimiter in my previous post, if you split it at that character sequence/delimiter, you would be able to separate the json string (which you are sending at the end of your output) from the leading non-json encoded output.

hielo 65 Veteran Poster

you have to return false when there is an error. Since you are NOT doing that, the form gets submitted and quickly reloaded (hence the "flash"). Try:

function validate() {
	var ok=true;
	ok=ok && firstname();
	ok=ok && lastname();
return ok;
}

function firstname() {

	var x=document.forms["signup"]["firstname"].value;
	if (x==null || x=="") {
		document.getElementById("error").style.visibility = "visible"; 
		document.signup.firstname.focus();
		return false;
	}
return true;
}
function lastname() {

	var x=document.forms["signup"]["lastname"].value;
	if (x==null || x=="") {
		document.getElementById("error").style.visibility = "visible"; 
		document.signup.lastname.focus();
		return false;
	}
return true;
}
hielo 65 Veteran Poster

You also need to echo json_encode()...; , and you can also send a particular character (or character sequence) where you can split the json string from everything else that has already been send. To clarify, it sounds like you have: ...blah......blah...{"title":"test"} Let's assume that your ...blah......blah... does NOT contain (and never will contain) "BaSk". So if you send that character sequence right before you json string, on the javascript end you can split it at that delimiter(character sequence):

<?php
echo 'Hello';
$propName="test";
$title = array("title" => "$propName");
echo 'BaSk';
echo json_encode($title);
exit;
?>
$.ajax({
			
			type : "POST",
			url : "sortProp.php",
			data : "f="+type+"&s="+filter,
			success : function(data){
			  var temp=data.split("BaSk");

                          //temp[0] should have Hello
                          //temp[1] should have the STRING {"title":"test"}

                          //convert it to an object
                          temp[1]=$.parseJSON(temp[1]);
				$('#propHold').html( temp[0] );
				$('#propHold .prop:first').addClass('active');
				
				alert(temp[1].title);
			
			}
		
		});
hielo 65 Veteran Poster

well, in that specific example I know that the properly encoded string appears after Hello, which consists of 5 characters, so I would skip the first five characters and use $.parseJSON() to convert the remainder of the string to an object:

success: function( data )
{
  var myobj=$.parseJSON(data.substring(5));
alert(myobj.title);
}
hielo 65 Veteran Poster

Ok, so if I were to use the following, would it still work?

$sql = "SELECT `name`,`owner` FROM table WHERE `verified`='1' AND name LIKE '$%term%' OR `owner` LIKE '%$term%'";

No! In that specific example, the query is treated as:

...
(`verified`='1' AND name LIKE '$%term%')
OR owner LIKE '%$term%'

In your case you clearly want the OR name with owner, so you must parenthesize that expression:

...`verified`='1' AND 
(name LIKE '$%term%' OR owner LIKE '%$term%')
hielo 65 Veteran Poster

if I change the data type to json, will i need to encode all data?

Yes, and that is the reason for your troubles.
For this to work: alert(data.title); the data you are returning must be:
a. ALL in json format
OR
b. you must parse the data parameter of your success function and YOU convert it explicitly.

To clarify on point b, let's say you have:

<?php
echo 'Hello';
$propName="test";
$title = array("title" => "$propName");
json_encode($title);
exit;
?>

that would end up sending the following to the browser: Hello{"title":"test"} since it is NOT a properly-encoded json string, it will NOT be "auto-converted" to a json object by jquery, so within success() , data is a string NOT a json object - that's why you cannot use data.title.

hielo 65 Veteran Poster

...i would like it to return a result whether only a name was found, just an owner, or both.

You don't need to AND. The OR should give you what you want even when both are true:

$sql="SELECT `name`, `owner` 
FROM Table WHERE `name` LIKE '$%term%' OR `owner` LIKE '%$term%'";
hielo 65 Veteran Poster

add dataType:'json' to your $.ajax() options. Also, make sure that your PHP file does NOT return anything after that json_encode statement - try:

<?php
$propName="test";
$title = array("title" => "$propName");
json_encode($title);
exit;
?>
hielo 65 Veteran Poster

You can only use document.write() WHILE the page is loading. If you use it AFTER the page has loaded, it will "erase" EVERYTHING that was already there and then write whatever new content you specify in the argument that you pass to document.write() . What you need is to NOT use the Refresh() at all. You need to designate an element with an ID to insert the new content into ("target element"). Then within NewDiv() use getElementById() to update that target element.

<html>
<head>
<script>
    
var div1 = "";
var div2 = "";
var div3 = "";
var div4 = "";
var div5 = "";
var div6 = "";
var div7 = "";
var div8 = "";
var div9 = "";

function NewDiv(type, target) 
{

  if(div1 == "")
  {
    div1 = "<div id='1' class='1'>"+type+"</div>";
  }
  else if(div2 == "")
  {
    div2 = "<div id='2' class='2'>"+type+"</div>";
  }
  else if(div3 == "")
  {
    div3 = "<div id='3' class='3'>"+type+"</div>";
  }
  else if(div4 == "")
  {
    div4 = "<div id='4' class='4'>"+type+"</div>";
  }
  else if(div5 == "")
  {
    div5 = "<div id='5' class='5'>"+type+"</div>";
  }
  else if(div6 == "")
  {
    div6 = "<div id='6' class='6'>"+type+"</div>";
  }
  else if(div7 == "")
  {
    div7 = "<div id='7' class='7'>"+type+"</div>";
  }
  else if(div8 == "")
  {
    div8 = "<div id='8' class='8'>"+type+"</div>";
  }
  else if(div9 == "")
  {
    div9 = "<div id='9' class='9'>"+type+"</div>";
  }
  target=document.getElementById(target);
  if(target)
    target.innerHTML=div1+div2+div3+div4+div5+div6+div7+div8+div9;
  else
    alert("Unable to locate element with id=" + target);
}
</script>
<style></style>
</head>
<body>
<form>
<select name="type" id="type">
<option value="header">Header</option>
<option value="navigation">Navigation</option>
<option …
hielo 65 Veteran Poster

first of all, fix line 41 so that you comment only the img tag, NOT that <a> tag.

then check the value of $Isbn. If it IS an empty string, then the if clause will not execute and your php code will not generate that link, which means that the browser will NOT get/see that link, leading you to the error you are seeing.

However if there are legitimate circumstances when that link will NOT be on the page, you need to first test the value returned by getElementById() :

...
var e =document.getElementById("pr_book");
if(e)
  e.style.display = '...';
...
hielo 65 Veteran Poster

ex: http. now i tried to put in there grab any src that does not start with http/s like this [^http:\/\/] but i guess that is not right.

when using brackets, each "item" in the bracket is treated/tested independently, NOT as a UNIT. To clarify,
b[ie]d

will match "bid" OR "bed", NOT "bied". This is equivalent to:
b(i|e)d


as far as implementing [^http:\/\/] , in the tutorial, read about
Positive and Negative Lookahead
Positive and Negative Lookbehind

but for what you are trying to do, you need a slight modification to my original suggestion (provided at the end of this post)

also when you do this s*() does it mean treat whats in there as a single string with 0 or more matching.

the expression I used was \s*. From the tutorial, it should be clear that \s stands for one of the "invisible" characters (blank/spacebar, \r, \n, \f).

So that "segment" of the expression is saying "...an invisible character zero or more times." The reason for this is that you can have: href = "..." notice the spaces around the equal sign. Yet, it is still perfectly valid html. As a matter of fact, this would have been better: href\s*=\s* As far as the parenthesis go, they are capturing parenthesis. Which leads me to your next question:

...and each [] within there is a variable like you put $1 and $2?

In the expression ([\x22\x27]) , the [\x22\x27]

hielo 65 Veteran Poster

I don't see the need for $contacts = array('id', 'other', 'email', 'substat'); I don't see the point of the if($contacts=='1') condition on your original post. If three items were checked, the code below should send an email to all three (it includes some lines I commented out from your original post:

//THIS IS WHERE, I SUSPECT, IS MY DOWNFALL
		//$contacts = array('other', 'email', 'substat');
		foreach ($_POST['contacts'] as $email=>$value)
		{
			$to=$email;
 
			//if($contacts=='1')
			//{
				//$to = $_POST['email'];
				$name = $_POST['name'];
				$visitor_email = $_POST['email'];
				$user_message = $_POST['message'];
				$subject="New form submission";
				$from = $your_email;
				$text = "A user  $name has sent you this message:\n $user_message";
 
				$message = new Mail_mime(); 
				$message->setHTMLBody($text); 
				$message->addHTMLImage($path_of_uploaded_file);
				$body = $message->get();
				$extraheaders = array("From"=>$from, "Subject"=>$subject,"Reply-     To"=>$visitor_email);
				$headers = $message->headers($extraheaders);
				$mail = Mail::factory("mail");
				$mail->send($to, $headers, $body);
				$mail=NULL;
			//}/*On your original post you are missing this HERE, on this line. You probably have it somewhere else, but it should be here. */

			//redirect to 'thank-you page
			header('Location: thank-you.html');
			exit;
		}
hielo 65 Veteran Poster

change:

mysql_select_db("lola", $con);

to:

mysql_select_db("lola", $con) or die( mysql_error() );

Most likely the user aby does not have any privileges on the lola db.

hielo 65 Veteran Poster

Glad to help.

Regards,
Hielo
PS: Don't forget to mark the thread as solved.

hielo 65 Veteran Poster

A. You need a space immediately before the value "keyword"
B. The value does NOT require the contacts prefix. Assuming the email is a@b.com and the id is 3, once submitted then:
echo $_POST will give you "contacts[3]" instead of just "3";

The changes below will "fix" this so that it give you only "3":

echo "<td><input type='checkbox' name='contacts[" . $row['email'] . "]'" . "  value='" . $row['id'] . "'" . "></td>";
hielo 65 Veteran Poster

Refer to:
https://github.com/douglascrockford/JSON-js/blob/master/json2.js

You will need to "import" that js script into your page, then call JSON.stringify( obj ) -ex:

<script type="text/javascript" src="/javascript/json2.js"></script>
<script type="text/javascript">
var settings={"username":"xxx","password":"secret"};
alert( JSON.stringify( settings ) );
</script>
hielo 65 Veteran Poster

instead of:

echo "\t"."Confirmation Page<br/>";

try:

echo "<div style='padding-left:10px;'>Confirmation Page</div>";
hielo 65 Veteran Poster

see http://www.regular-expressions.info/tutorial.html
(The left column is basically a list of links to the "Table of Contents")

and if you are interested in a book, this one is definitely worth it:
http://www.amazon.com/Mastering-Regular-Expressions-Second-Jeffrey/dp/0596002890

hielo 65 Veteran Poster

try:

preg_replace('/href=\s*([\x22\x27]?)([^\.]+\.css)/i', 'href=$1'.$dir.$template.'$2', $content);
hielo 65 Veteran Poster

currently I see the following on line 148: $to = $_POST['email']; but on line 33 you have: <input type="text" name="vemail" > Notice that the name of the input text box does NOT match the key in the $_POST array. If you fix the name of the input field (get rid of that "v"), then you should be able to type a comma-separated list of email addresses and all of them will get the same email message.

As far as the foreach goes, given this:

$contacts = array('other', 'email', 'substat');
foreach ($contacts as $email) {
  $email = $to;
}

A. assigning the variable $to to the varialbe $email doesn't make sense since on the very first time that statement is executed $to doesn't exist at that point.

B. as far as understanding arrays, it will make more sense if you can see/understand that this:

$contacts = array('other', 'email', 'substat');

is equivalent to:

$contacts = array('0'=>'other', '1'=>'email', '2'=>'substat');

Armed with that knowledge, look up the foreach on the manual:
http://us3.php.net/manual/en/control-structures.foreach.php

Notice the second syntax?
So basically if you do:

$contacts = array('other', 'email', 'substat');
foreach($contacts as $index=>$value)
{
  echo $index.'='.$value.'<br/>';
}
//output should be:
0=other
1=email
2=substat

So, I hope that clarifies how the foreach works.

C. As far as your project goes, I suspect what you actually want is for the user to be able to check multiple users and then email only the checked individuals. If that is the case, then the problem …

hielo 65 Veteran Poster

try:

<?php
	$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die("Unable to connect to the db server");

	$parent_id = mysqli_real_escape_string($dbc, $_GET['parent_id']);

	$comment_query = "SELECT comment_id,poster_id,comment_text,post_time FROM comments WHERE parent_id = '$parent_id' ORDER BY post_time ASC";
	$comment_data = mysqli_query($dbc, $comment_query);
	
	$xmlOutput = '<?xml version="1.0"?>';
	$xmlOutput .= '<comments>';
	
	while( $comment_rows = mysqli_fetch_assoc($comment_data) ){
		//Get username
		$username_query = sprintf("SELECT username FROM wwit_user WHERE user_id = '%s' LIMIT 0, 1", mysqli_real_escape_string($dbc, $comment_rows['poster_id']);
		$username_data = mysqli_query($dbc, $username_query);
		$username_rows = mysqli_fetch_assoc($username_data);

		$xmlOutput .= '<comment>';
			$xmlOutput .= '<comment_id>'. htmlentities($comment_rows['comment_id'],ENT_QUOTES) .'</comment_id>';
			$xmlOutput .= '<poster_id>'. htmlentities($comment_rows['poster_id'],ENT_QUOTES) . '</poster_id>';
			$xmlOutput .= '<poster_name>'. htmlentities($username_rows['username'],ENT_QUOTES) .'</poster_name>';
			$xmlOutput .= '<comment_text>'. htmlentities($comment_rows['comment_text'],ENT_QUOTES) .'</comment_text>';
			$xmlOutput .= '<comment_time>'. htmlentities($comment_rows['post_time'],ENT_QUOTES) .'</comment_time>';
		$xmlOutput .= '</comment>';
		mysqli_free_result($username_data);
	}
	mysqli_free_result($comment_data);
	$xmlOutput .= '</comments>';
	header('Content-Type: application/xml;');
	echo $xmlOutput;
exit;
?>
hielo 65 Veteran Poster

On my previous post, COMMENT OUT line 302:

...
/*    		$add_cocurriculumevaluation = mysql_query($insert) or die('Line '.__LINE__.': '.mysql_error());
*/
...

If you are still having problems, post a link to your page So I can see the markup that your script is generating.

Regards,
Hielo

hielo 65 Veteran Poster

Warning: Invalid argument supplied for foreach()

Well, if no item is checked, then there $_POST would NOT be an array, and the argument to the foreach would be invalid - triggering the warning you are seeing. You need to make sure the user has posted all the required fields first.

On another note, $ccc=$_POST['choice[]']; (around line 203) doesn't make sense. To derefence an "array" of checkboxes, even though you code it as <input type="checkbox" name="choice[]" /> , in your PHP you do NOT use the brackets to derefence the posted/submitted item. So strictly speaking it should simply be: $ccc=$_POST['choice']; Having said that, even if you correct line 203 as indicated, the $ccc still doesn't make sense, because $ccc would have an Array() . What you need to do is to iterate over the choice array and foreach item in the array insert it into the db. This means that $ccc should really be the same value as $v in your foreach() . So, all those sql statements seem to depend on the checked items need to be within the foreach construct, and also, within the foreach , assign $v to $ccc .

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="javascript" type="text/javascript" src="datetimepicker.js">

//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
//Script featured on JavaScript Kit (http://www.javascriptkit.com)
//For this script, visit http://www.javascriptkit.com 

</script>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style101 …
hielo 65 Veteran Poster
//print_r() is to print an array. Preview is NOT an array. 
//You can print the entire $_REQUEST array:
print_r($_REQUEST);

//OR just the Preview item:
echo $_REQUEST['Preview'];

Also, make sure the button is WITHIN the form.

Lastly, if there is more than one form on the page, the first form on the page is likely to be submitted first. I would suggest you give the form in question an id:

<form id="myForm"...>

then use:
$('input.preview').click(function() {
		
		$('#myForm').attr( 'target', '_blank' ).trigger('submit');
         	/* document.myform.submit(); */
	});
hielo 65 Veteran Poster
<script>
var monthtext=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec'];

function populatedropdown(dayfield, monthfield, yearfield){
	var today=new Date()
	var dayfield=document.getElementById(dayfield);
	var monthfield=document.getElementById(monthfield);
	var yearfield=document.getElementById(yearfield);

	for (var i=0; i<31; i++)
		dayfield.options[i]=new Option(i+1, i+1)
	dayfield.options[today.getDate()-1].selected=true;

	for (var m=0; m<12; m++)
		monthfield.options[m]=new Option(monthtext[m], monthtext[m])
	monthfield.options[today.getMonth()].selected=true;
	var thisyear=today.getFullYear()
	for (var y=0; y<20; y++){
		yearfield.options[y]=new Option(thisyear, thisyear)
		thisyear+=1
	}
yearfield.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true) //select today's year
}

onload=function(){
	 populatedropdown('d', 'm', 'y')
};
</script>
<select id='m' name='month'></select>
<select id='d' name='day'></select>
<select id='y' name='year'></select>
hielo 65 Veteran Poster

It would help if you actually post the HTML you are using. As for:

//element.style.visibility = 'hidden' and 'block'
element.style.visibility  ==> visible OR hidden
element.style.display     ==> none OR block OR inline

So if you have an input and next to is is the element you want to display (like a span), then use display:inline. If you were to use display:block, then it would appear on a line by itself.
hielo 65 Veteran Poster
<script type="text/javascript">
function trim(str){
	return String(str).replace(/^\s+|\s+$/g,'');
}
function checkForm(formobj)
{
	//name
	var formOK = true;
	
	if (formobj.name.value == "") 
	{
		window.alert("You have to enter value for name.");
		formobj.focus();
	formOK = false;
	}

	//surname
	if (formobj.surname.value == "") 
	{
		window.alert("You have to enter a value for surname.");
		formobj.focus();
		formOK = false;
	}

	//identity number (presence)
	formobj.ID.value=trim(formobj.ID.value);
	if (false==/^\d{9}$/.test(formobj.ID.value) ) 
	{
		window.alert("You have to enter an identity number with strictly nine (9) digits.");
		formobj.focus();
		formOK = false;
	}

	/*
	The above check makes sure the value of ID is EXACTLY 9 digits
	//identity number(length)
	if (formobj.ID.length != 9) 
	{
		window.alert("The ID number has to have nine (9) values.");
		formobj.focus();
		formOK = false;
	}
	*/
return formOK;
}
</script>
hielo 65 Veteran Poster

There are "plugins" for this already. I suggest you look at:
http://bassistance.de/jquery-plugins/jquery-plugin-treeview/

Click on the demos link. It shows you MULTIPLE trees on a single page. If you want to see a demo with a single tree, then click on any of the links at the top of the demo page. Once you are on the page with the single demo, you can look at the browser's source code to see the needed markup.

PS: If you decide to use the plugin above, be sure to read the Documentation link

hielo 65 Veteran Poster

post your html code (and css if any)

hielo 65 Veteran Poster

...also tried xmlDoc.documentElement.NodeName.

Try lowercase "N" for Node
xmlDoc.documentElement.nodeName.

If the problem persists, verify that the document loaded correctly - on line 4 put: Response.Write(xmlDoc.xml); If you do not see the xml document, then it was not retrieved.

hielo 65 Veteran Poster
function makeUppercase(field) {
	field.value = field.value.replace(/(, [a-z])/g,function(){return arguments[1].toUpperCase()});
}
hielo 65 Veteran Poster

document.layers? Seriously?
For your reference:
http://www.webconcerns.co.uk/javascript/dhtml/dhtml_page.asp

Try:

<style type="text/css"> 
a
{
	text-decoration: none;
}
 
.title
{
	position: absolute;
	width: 150px;
	height: 20px;
	left: 10=px;
	z-index: 10;
	font-family: verdana, helvetica, sans-serif;
	font-weight: bold;
	font-size: 12px;
}
 
.submenu
{
	position: absolute;
	left: 25px;
	width: 120px;
	border: 0px solid black;
	background-color: white;
	layer-background-color: white;
	font-family: verdana, helvetica, sans-serif;
	font-size: 10px;
	visibility: hidden;
}
</style>
 
<script type="text/javascript">

//nom is the number of menus on your tree, change this if your want more menus
var nom = 16; // Number of menus
var usePictures = 1;
 
var ttls = new Array();
var subs = new Array();
var lastn;
var lastmove;

/*
if (document.layers) {
	visible = 'show';
	hidden = 'hide';
}
else if (document.all) {
	visible = 'visible';
	hidden = 'hidden';
}
*/
var	visible = 'visible';
var	hidden = 'hidden';

for (var i = 1; i <= nom; i++) {
	ttls[i] = ('title' + i);
	subs[i] = ('submenu' +i);
}
function picopen(n) {
	pic = ('pic' + n);
	/*
	title = ('title' + n);
	if (document.layers) {
		document.layers[title].document.images[pic].src = "open.gif";
	}
	else if (document.all) {
		document.all(pic).src = "open.gif";
	}
	*/
	if (document.getElementById) {
		document.getElementById(pic).src = "open.gif";
	}
	else if (document.all) {
		document.all(pic).src = "open.gif";
	}

}
function picclose(n) {
	pic = ('pic' + n);
	/*
	title = ('title' + n);
	if (document.layers) {
		document.layers[title].document.images[pic].src = "closed.gif";
	}
	else if (document.all) {
		document.all(pic).src = "closed.gif";
	}
	*/
	if (document.getElementById) {
		document.getElementById(pic).src = "closed.gif";
	}
	else if (document.all) {
		document.all(pic).src = …
hielo 65 Veteran Poster

Line 23 should have been */. I was trying to comment out lines 18-23.

Regards,
Hielo

hielo 65 Veteran Poster

...To make it send and save to the php file without being forwarded to it and then save it to work for my website.

I don't quite understand what you are saying. Can you be more clear?

hielo 65 Veteran Poster
//I you had:
//<input type="text" id="email" name="emailAddress">
//then 
var x = document.getElementById('email');

//will cause x to have a REFERENCE to the element whose id="email"
//which in this case is your <INPUT> with name="emailAddress"
//NOTICE: You must use the value of the id NOT the value of name
//for this reason, an id MUST be unique throughout the document.
//
//now that x holds a reference to x, you can retrieve its properties
alert( x.value );
alert( x.id );
alert( x.name );
alert( x.type );

//you can assign a new value to it, like a string:
x.value="hello"

//or even a number
var PI=3.141
x.value = PI;

//of a number to 1 decimal place
x.value = PI.toFixed(1);

Strictly speaking, you are NOT required to save the reference onto another variable first:

//saving onto x is optional
var x = document.getElementById('email');

//if you are going to be needing or using a single property for a given element, 
//it may be easier/"more convenient" to access the property immediately
document.getElementById('email').value="Howdy";

//the script engine first figures out that document.getElementById('email') is a 
//reference to the element with id="email", then it accesses its value property 
//and assigns it "Howdy"
hielo 65 Veteran Poster
$(document).ready(function(){
 
	$("#env").click(function(e) {
 
			e.preventDefault();

			var r1='';
			var r2='';
			$.get("char_con.php?", {act: 'char_con'}, function(data){
				//save the result of the first call onto r2
				r1=data;
			});
			
			$.getJSON("generator.php?", {act: 'char_con', bc: '1'}, function(data){
				//save the result of the second call onto r2
	 			r2=data;
			});

			//take both results and save them onto .q
			$(".q").html( r1 + r2);
	});
	
});
hielo 65 Veteran Poster

On my previous post, replace line 69 with the following: $data=implode(PHP_EOL, array_combine( array_keys($_POST), $_POST) . PHP_EOL . PHP_EOL;

hielo 65 Veteran Poster
<?xml version= "1.0: encoding = "utf-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">



<!-- homework 9.19 -->

<html xmlns = "http://www.w3.org/1999/xhtml">

<head>
<title> Fahrenheit and Celsius Converter </title>

<script type = "text/javascript">

//make convertC function
function convertC()
{

  //get the number form field
var field1 = document.getElementById("Celsius");
var temp1 = parseFloat(field1.value);
var answer1 = 0;

answer1 = (5.0/9.0) * (temp1 - 32);
 document.getElementById("Fahrenheit").value=answer1.toFixed(1);
return answer1;
}

//make converF funtion
function convertF()
{
var field2 = document.getElementById("Fahrenheit");
var temp2 = parseFloat(field2.value);
var answer2 = 0;

answer2 = (9.0/5.0) * (temp2 )+ 32;
document.getElementById("Celsius").value=answer2.toFixed(1);
return answer2;
}
</script>

</head>

<body>

<h1> Fahrenheit and Celsius Converter </h1>

<table border = "1" width = "35%">

<thead>

<tr>

  <td>Fahrenheit</td>
  <td><input id = "Celsius" type = "text" size = "25" /></td>
  <td><input type = "button" value = "Convert to Celsius"
        onclick = "convertC()" </td>
</tr>
<tr>
  <td>Celsius</td>
  <td><input id = "Fahrenheit" type = "text" size = "25" /></td>
  <td><input type = "button" value = "Convert to Fahrenheit" 
        onclick = "convertF()"</td>
</tr>

</table>

</body>

</html>
hielo 65 Veteran Poster

Try:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<form method="post" action="processIt.php">
  <div><label for="">Name</label><input type="" name="Hi_my_name_is_" value="" /></div>
  <div><label for="">Email</label><input type="" name="Email" value="" /></div>
  <div><label for="">Phone Number</label><input type="" name="Phone_Number" value="" /></div>
  <div><input type="Submit" name="_SendIt" value="Submit"/></div>
</form> 
</body>
</html>


processIt.php
<?php
//specify the name of the file where you will be saving the data
$filename=getcwd().'/data.txt';

//check to see if anything was posted
if( isset($_POST) && !empty($_POST) )
{
	//if you make it here, then something was submitted via post, which would
	//be contained in the $_POST array
	
	//here I am "adding" the timestamp to the $_POST array so that it will be recorded
	//in the textfile along with the posted data
	$_POST['timestamp']=date('Y-m-d H:i:s');

	//here I am iterating over the contents of the $_POST array
	foreach($_POST as $fieldName=>$fieldValue)
	{
		//if you look at the HTML form I gave you, the Submit button has
		// name="_SendIt". You most likely are NOT interested in saving the value
		//of the button, since this will be the same always. So you can check to see if
		//the value is "_SendIt" and choose to skipt it, but a more general solution
		//would be to prefix all the field that you do NOT want saved with an underscore
		//and then filter out ANY field that starts with an underscore, which is what 
		//the following is doing.
		
		//this locates the fields whose name starts with an underscore
		if( '_'==$fieldName[0] )
		{
			//this removes it from $_POST …
hielo 65 Veteran Poster

Look at line 27 on your ORIGINAL post. There you are computing the answer and assigning it to answer1.

On line 29 you are returning the computed result (the converted temperature value). What I am suggesting is that on line 28 you add:
document.getElementById("Fahrenheit").value=answer1;

The same logic applies for the other function. Look at my previous post.

hielo 65 Veteran Poster

at the end of line 7 of your second code block you have: function(data{ It is missing a closing parenthesis. Try:

$(document).ready(function(){

	$("#env").click(function(e) {

		e.preventDefault();

                        // do both
                        $.getJSON("generator.php?", {act: 'char_con', bc: '1'}, function(data){

			$(".quote").html(data);


		});

                        $.get("char_con.php?", {act: 'char_con'}, function(data){							  
        			$(".q").html(data);
         		});

			$(".q").html(data);
			
		});
	});
});
hielo 65 Veteran Poster

try:

function checkAdd(){
	
	var cname = document.getElementById('addname');
	var cpound = document.getElementById('addpound');
	var cpence = document.getElementById('addpence');
	var div = document.getElementById('errormsg');
	var lets = /^[a-zA-Z\s]+$/;
	var nums = /^[0-9]+$/;
	
	if((cname.value == '') || (cname.value == ' '))
	{
		div.innerHTML= "<b>Please fill in the item name</b>";
		cname.focus();
		return false;
	}
	else if(cname.value.match(lets))
	{
	/*
		if(cpound.value == '')
		{
			cpound == 0
		}
/*		
		if(cpound.value.match(nums))
		{
			if((cpence.value == '') || (cpence.value == ' '))
			{
				div.innerHTML= "<b>Please fill in value for pence</b>";
				cpence.focus();
				return false;
			}
			else if((cpound.value.length == 1) && (cpence.value.length == 1))
			{
				div.innerHTML= "<b>Please enter 2 digits for pence</b>";
				cpence.focus();
				return false;
			}
			else if(cpence.value.match(nums))
			{
				return true;
			}
			else
			{
				div.innerHTML= "<b>Only numbers please</b>";
				cpence.focus();
				return false;
			}
		}
		else
		{
				div.innerHTML= "<b>Only numbers please</b>";
				cpound.focus();
				return false;
		}
	}
	else
	{
		div.innerHTML= "<b>Only letters please</b>";
		cname.focus();
		return false;
	}
return true;
}
hielo 65 Veteran Poster

when the pound and pence fields on the form are blank, but the name is filled in

Not from what you coded. The problem is that when the pound is left blank, this condition is true:

if(cpound.value == '')
		{
			cpound == 0
		}

and the rest of your code ( within the else if-else ) will NOT execute, eventually leading to the "return true". Hence the reason it is submitting.