1,076,007 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

Posts by wblakenc

Ok I think the answer is to use XSLT to sort the items I want..... I said I was new! Sorry for the dumb question!!!

wblakenc
Newbie Poster
19 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

I am very new to using XML and I have what should be an easy solution but google is failing me. I have one xml document with different data sets in it (see code below). What I want is to only work with one set of data at a time.

Here is a sample XML doc:

<CATALOG>
  <CD>
	<TITLE>Picture book</TITLE>
	<ARTIST>Simply Red</ARTIST>
	<COUNTRY>EU</COUNTRY>
	<COMPANY>Elektra</COMPANY>
	<PRICE>7.20</PRICE>
	<YEAR>1985</YEAR>
  </CD>

  <CD>
	<TITLE>Red</TITLE>
	<ARTIST>The Communards</ARTIST>
	<COUNTRY>UK</COUNTRY>
	<COMPANY>London</COMPANY>
	<PRICE>7.80</PRICE>
	<YEAR>1987</YEAR>
  </CD>

  <TAPE>
        <TITLE>Unchain my heart</TITLE>
	<ARTIST>Joe Cocker</ARTIST>
	<COUNTRY>USA</COUNTRY>
	<COMPANY>EMI</COMPANY>
	<PRICE>8.20</PRICE>
	<YEAR>1987</YEAR>
  </TAPE>
  <TAPE>
        <TITLE>The dock of the bay</TITLE>
	<ARTIST>Otis Redding</ARTIST>
	<COUNTRY>USA</COUNTRY>
	<COMPANY>Atlantic</COMPANY>
	<PRICE>7.90</PRICE>
	<YEAR>1987</YEAR> 
  </TAPE>
</CATALOG>

In the above example I would like to extract the data sets that are in the CD category first and the TAPE category second. How do I do this? I am able to parse the entire XML doc into an array that I can access using standard array syntax (i.e. xmlChildren[1]). But that gives me only one node or one specific title, how do I restrict to a specific type? Is there some way using the XML DOM to only reference a specific type?

Any suggestion or comment, or question would be greatly appreciated!

wblakenc
Newbie Poster
19 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

That works, well sorta...

It seems it does exactly what it should and ends the each row with a </tr>, except when it starts a new row it appends that data to all previous rows.

So lets say I type in 10 offices

So I get the first row with offices 1 - 10
second 4-10
third 7-10
fourth 10

I put some window.alert breaks in there to better see what it is doing and it is working except now it is appending to all the previous rows, which I guess makes sense because i am telling it to append to a tr inside table p.

Is there anyway make sure it is appending to the correct row by putting some sort of variable in the statement (I have tried the following and it does not work):

$("#p").append("<tr id=row" + tracking + ">");
$("#p #row" + tracking).append("<td>" + tracking + ")" + "&nbsp;&nbsp;&nbsp;<input type='text' size='50' name='Office" + tracking +"' /></td>");

Any idea?

wblakenc
Newbie Poster
19 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

Ok here is what I am trying to. I have a form where a user will enter in the number of input fields they need (lets call them offices) and when they click the submit button a jQuery function appends the rows to a plain html table. This works fine, except I do not want the rows to be only vertical or horizontal. I want it to put three input fields on one row before going to the next. Here is the code I have:

//This function is for adding rows to the offices table
function addOfficeRows() {
	var i = 0;
	var counter = document.getElementById("oNum").value;
	var tracking = document.getElementById("officeTracking").value;
	var tracking = parseInt(tracking);
	// second counter which helps determine if a new row should start or not //
	var second = 1;
		for(i=1;i<=counter;i++) {
			if (second == 1) {
				$("#p").append("<tr>");
				$("#p").append("<td>" + tracking + ")" + "&nbsp;&nbsp;&nbsp;<input type='text' size='50' name='Office" + tracking +"' /></td>");
				second = second + 1;
			} else if (second == 2) {
				$("#p").append("<td>" + tracking + ")" + "&nbsp;&nbsp;&nbsp;<input type='text' size='50' name='Office" + tracking +"' /></td>");
				second = second + 1;
			} else if (second == 3) {
				$("#p").append("<td>" + tracking + ")" + "&nbsp;&nbsp;&nbsp;<input type='text' size='50' name='Office" + tracking +"' /></td>");
				$("#p").append("</tr>")
				second = 1;
			}
			tracking += 1;		
		}		
	document.getElementById("officeTracking").value = tracking;
	document.getElementById("officeAddRows").value = "Add More Fields";		
	
}

What happens is the <tr></tr> are getting appended to a "tbody" tag and rest is put outside of that tag, meaning the table is formed vertically. Any idea? Am I using append incorrectly? I am by no means an expert in jQuery so I am open to suggestions.

Thanks!

wblakenc
Newbie Poster
19 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

Ok after doing some more research (and searching the forum) I have obviously found others asking the same thing (without much help). Just to clarify, I want to be able to print to a printer connected on the host computer because this php script is not being used on the web it is being used on a computer that is both the host and end users computer. If I cannot use PHP for this, how can I do it.

Thanks,
Will

wblakenc
Newbie Poster
19 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

I am currently running IIS 7 on window vista business (64 bit) with PHP 5.3.1 installed and operating correctly. I have also installed PEAR and that is running correctly. What I want to do is use the Printer functions but can't seem to figure out how to get it to work. I have tried downloading PECL extension but when I go to: http://pecl.php.net/ and click on download newest it says file not found. So it is not exactly that I cannot get it to work, just cannot find and figure out how to install the extension.

So I am wondering if this has been removed in more recent versions of PHP? If I cannot use the PECL printer function, what else can I use?

Any ideas would be greatly appreciated.

Thanks in advance.

Will

wblakenc
Newbie Poster
19 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

Just to make it clear here is the code for what the user clicks on a menu option a sub menu shows up with the following options.

<div id="rampsMenu">
        <a href="javascript:;" onclick="expand_ramps()"><img src="cw3/assets/images/leftNav/Ramps.jpg" border="0" /></a><br />
        <a href="javascript:;"><img src="cw3/assets/images/leftNav/ThresholdRamps.jpg" border="0" /></a><br />
        <img src="cw3/assets/images/leftNav/SuitcaseRamps.jpg" border="0" /><br />
        <img src="cw3/assets/images/leftNav/SingleFoldRamps.jpg" border="0" /><br />
        <img src="cw3/assets/images/leftNav/MultiFoldRamps.jpg" border="0" /><br />
        <img src="cw3/assets/images/leftNav/PanelRamps.jpg" border="0" /><br />
        <img src="cw3/assets/images/leftNav/PathwayRamps.jpg" border="0" /><br />
        <img src="cw3/assets/images/leftNav/CurbCutRamps.jpg" border="0" /><br />
        <img src="cw3/assets/images/leftNav/ShowAllRamps.jpg" border="0" /><br />
    </div>

The first link makes the sub menu show up, and the first link on that menu (Threshold Ramps) is currently liked to nothing (i.e. javascript: ; ).

Here is the JavaScript I am using to make this happen.

function expand_ramps(value) {	
	/* check to see if menu is already open */
	if (this.RampsOpen == 'Yes') {
		document.getElementById("rampsMenu").style.height = "20px";		
		this.RampsOpen = 'No';
	/* if the menu is currently not open, send it to drawInfo to perform the draw down effect */	
	} else {		
		var res = document.getElementById("rampsMenu");
		/* element, goal size, starting size */
		drawInfo(res,160,10);
		this.RampsOpen = 'Yes';		
	}
}

function reset_all() {
	document.getElementById("rampsMenu").style.height = "20px";		
}

function drawInfo(element, goal, start) {
	var GoalPt = goal;	
	element.style.height = (start)+"px";	
	element.style.clip="rect(0px, 222px, "+start+"px"+", 0px)";		
	var newvalue = start + 10;
	var repeat = function () {		
		drawInfo(element,GoalPt,newvalue)
	};
	if (newvalue >= GoalPt) {
		return;
	} else {
	element.info = setTimeout(repeat,1);
	}
}
wblakenc
Newbie Poster
19 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

Hello all,
I have run into an issue with an JavaScript expand menu (you click a menu option a sub-menu shows, moving the other main navigation menu options down).

Well I have designed a nice custom script to do just this. The problem is, how do I keep that sub-menu shown when the user clicks a link and the page refreshes. Basically I need a way to check to see if the menu has been opened before, and if so, keep it open on the new page. How does one do this? URL variable? Setting some sort of cookie? I know if I were doing something like this in ColdFusion I would just set a session, or other variable that persists page after page, but JavaScript has no such function?

Any Idea?

Thanks for any and all help!

Will

wblakenc
Newbie Poster
19 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

Humm... Maybe I do not understand what you are trying to do, because if you have two products with the same ingredient you will get duplication of that ingredient. I am not sure that is avoidable, however you should not be getting different lot_ids.

I am having trouble understanding your example tables. So I attached a screen shot of what I put together and maybe you can tell me what I am doing differently.

Attachments recipesTable.jpg 15.46KB lotTable.jpg 10.21KB
wblakenc
Newbie Poster
19 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

Let me re-phrase what you are saying to see if I get it.
You have a table called recipes and a table called lots. These two tables are linked by ingredients. What you want is the user to be able to select a product and get from the database what the lot id is for the ingredient(s) that goes into the recipe.

This should be a pretty simple inner join.

Try the following query (making changes to the column names as needed):

SELECT *
from recipes r inner join lots l on l.lot_ingredient = r.ingredient

If that works, let me know and I can get you the rest of the way.

wblakenc
Newbie Poster
19 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

Can you not just join the two tables using an inner join?
I suspect you can do what you need with one query, but I have to know more about your table design with the primary and foreign keys.

wblakenc
Newbie Poster
19 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

You had a few problems with your code. First you still had the OR statement in the javascript area that checked to see if someone had put either their telephone or cellphone number. This should be an AND. Why? Simple. You are checking to see if the first and second box are empty meaning the user did not put in one or the other.

The second problem you had is the check that validated the phone number boxes returned true if the validation passed. The problem with this is you never let the javascript get to the validation for the check box. You only need one return, and that return should be after the check box.

The last problem you had was some extra parenthesizes around the if statement that checked if the check box was checked or not. Also I found that the form did not have an id which was causing some issues in Firefox. I have added the id named 'form1'. I also removed the "with(form)" because I do not see any reason why you need it.

Below you will find your code with my edits. Let me know if you have any questions.

<html>
<head>
<title>DEMO</title>

<script type="text/javascript"><!--

function validate(form) {

	
if (( form.conPerP1.value == "" ) && ( form.conPerP2.value == "" ))
	 {
     alert("Please enter your telephone or cell no. to continue.");
     form.conPerP1.focus();
      return false;
      } 
		
	if(!form.agreement.checked) {
	  alert("Please commit the agreement to continue.");
	  form.agreement.focus();
	  return false;
	    } return true; 
	  }


// --></script></head>

<?php
if(isset($_POST['put'])){
echo $_POST['conPerP1'];
echo $_POST['conPerP2'];
}
 ?>
<form method="POST" action="" id="form1" onsubmit="return validate(this)">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%" height="160">
<tr>
    <td width="25%" height="32" align="right"><font face="Calibri">Contact Person Phone No. 1:</font></td>
    <td width="75%" height="32">&nbsp;
	<input type="text" name="conPerP1" size="20"></td>
  </tr>

  <tr>
    <td width="25%" height="20" align="right"><font face="Calibri">Contact Person Phone No. 2:</font></td>
    <td width="75%" height="30">&nbsp;
	<input type="text" name="conPerP2" size="20"></td>
  </tr>

  <tr>
    <td height="30" colspan="2" align="left"><font face="Calibri">
    <input type="checkbox" name="agreement" value="checkbox"> I agree all the terms & conditions of this website </font></td>
  </tr>

 </table>
  <p align="center">
	<input name="put" type="submit" value="Submit" >
  </p>
</form>
</body>
</html>
wblakenc
Newbie Poster
19 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

Like I said there are a few different ways to do this. The following is what put together for you.

Put the following in the document head:

<cfquery datasource="yourDatasource" name="menu1">
SELECT value, option
from SOME TABLE THAT HAS MENU1 DATA
</cfquery>

<cfquery datasource="yourDatasource" name="menu2">
SELECT value, option
from SOME TABLE THAT HAS MENU2 DATA
</cfquery>


<script type="text/javascript">

function makeChange(form) {
	if (form.radio1[0].checked) {
		document.getElementById("showMenu1").style.visibility="visible";
		document.getElementById("showMenu2").style.visibility="hidden";
		form.menu2.selectedIndex = 0;

	}
	if (form.radio1[1].checked) {
		document.getElementById("showMenu2").style.visibility="visible";
		document.getElementById("showMenu1").style.visibility="hidden";
		form.menu1.selectedIndex = 0;		

	}
}


</script>
<style type="text/css">
#showMenu1 {
visibility:hidden;
}
#showMenu2 {
visibility:hidden;
}
</style>

The above code does a few things. First it gets the data for the drop down menus by polling your database. If the data for these two menus are in the same table (which would make sense) you will need to include a WHERE clause in the above queries. These values are put into two drop down menus that appear or disappear depending on which radio button is checked. The following code will be found in the document body:

<form action="" method="post">
<input type="radio" id="radio1" name="radio1" value="Yes" onClick="makeChange(this.form)" />Yes <input type="radio" id="radio1" name="radio1" value="No" onClick="makeChange(this.form)" />No
<div id="showMenu1">

<select name="menu1">
<option value="" selected="selected">Select One</option>
<cfoutput query="menu1">
<option value="#value#">#option#</option>
</cfoutput>
</select>
</div>

<div id="showMenu2">

<select name="menu2">
<option value="" selected="selected">Select One</option>
<cfoutput query="menu2">
<option value="#value#">#option#</option>
</cfoutput>
</select>
</div>
</form>

I hope this helps.

wblakenc
Newbie Poster
19 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

You know I spent about a half hour (maybe longer) trying to figure out what you were doing wrong. I cut your code down to the min and just had the if statement that checked to see if one OR the other phone number was blank. I couldn't figure it out until it dawned on me. You are using an OR when you should be using an AND!!!! It is not if one or the other is bank (as written in the Alert message), it is one and the other is blank (i.e. they are both blank) that you want it to error out.

On a side note, you really do not need as much code as you have to do this check. I am not sure why you have the Try/Catch statements in the validation.

The following is sufficient (at least when looking at the code you posted).

<html>
<head>
<title>DEMO</title>
<script type="text/javascript">
<!--
function validate( form ) {
   
   if ( !form.agreement.checked ) {
     alert ("Please commit the agreement to continue.");
     form.agreement.focus();
     return false;
     }
   if (( form.conPerP1.value == "" ) && ( form.conPerP2.value == "" )) {
     alert("Please enter your telephone or cell no. to continue.");
     form.conPerP1.focus();
      return false;
    } return true;  
  }
 
// -->
</script>
</head>
<body>
<form id="form1" action="#" onsubmit="return validate( this );">
<div>
<label for="agreement"><input type="checkbox" id="agreement" name="agreement" value="" /> I agree</label><br />
<label for="conPerP1">Tel: <input type="text" id="conPerP1" name="conPerP1" size="10" value="" /></label><br />
<label for="conPerP2">Mobile: <input type="text" id="conPerP2" name="conPerP2" size="10" value="" /></label><br />
<input type="submit" id="sbm" name="sbm"  value="submit" />
</div>
</form>
</body>
</html>
wblakenc
Newbie Poster
19 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

Perfect! This is what i was thinking, but just wanted to make sure I fully understood why and when I would need an intermediate table.

Thanks again for the help.!

wblakenc
Newbie Poster
19 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

Posted this in the wrong area... Sorry!

I know this should be in the database design area, however I was too quick to select MySQL as that is what I am using.

wblakenc
Newbie Poster
19 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

What do you see in the wwwroot under:
C:\ColdFusion8\wwwroot\

I suspect your problem is you have either put the files into the wrong folder or are looking in the wrong folder.

wblakenc
Newbie Poster
19 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

You have to do a few different things. First ColdFusion being a Server Side Programming language, there is no way to do what you want using ColdFusion directly. You will have to use Javascript to dynamically link the drop down menus to an array that is populated by ColdFusion.

Another way to do it would be to have CF populate both dropdown menus and use javascript to control which is visible (using CSS) depending on which radio button you select.

I hope this puts you in the right direction.

wblakenc
Newbie Poster
19 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

Hello everyone,
I have a fairly simple question about database design. I have a database for county voting equipment. Each county has multiple pieces of voting equipment. I currently have two tables, one with counties and one with voting equipment. Is there any reason to have a relational table between them or is it sufficient to have a county ID field in the equipment table and link them that way. Is there any pro to having a intermediate table between counties and equipment? Any drawback with linking them directly?

Thanks in advance.

wblakenc
Newbie Poster
19 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0
 
© 2013 DaniWeb® LLC
Page rendered in 0.1523 seconds using 2.6MB