Jump to content

chiprivers

Members
  • Posts

    468
  • Joined

  • Last visited

    Never

Everything posted by chiprivers

  1. Well I have sorted the first problem myself. I have disabled the right click menu by adding the following to the required elements: oncontextmenu="return false;" Just need some help with a script to create my own pop up menu.
  2. Before anyone says it, I am not trying to protect my source code by disabling the right click menu in my script! What I want to achieve is when the right mouse button is clicked within certain elements of my page, an alternative right click menu is displayed. I have the following function to put within the onmousedown property of the required elements to detect the right mouse button: function rightClick (e) { var rightclick; if (!e) { var e = window.event; } if (e.which) { rightclick = (e.which == 3); } else if (e.button) { rightclick = (e.button == 2); } if (rightclick) { // disable standard right click menu // display alternative right click menu } } Could anybody please help me with the last couple of bits commented in this function?
  3. Honestly, I did try google first and couldn't find the answer to this one. But I googled, and googled a bit more and found the solution! parseInt()
  4. Is it possible to change the type that a variable is being stored as? I have a var which is behaving like a string but contains a number. I am assuming that it is behaving like a string due to the way that its value is extracted and applied to the var. Below is an example to demonstrate what I mean by behaving like a string: var x = 10000; var y = 999; var z = x + y; In my script, the above value for z is displaying as 10000999 when I want it to be adding the values so should be 10999. Is there a way that once a var has a value applied, if it is stored as a string, I can change it to be numerical?
  5. Many thanks mjdamato. The commented out first line was an error! I was commenting out various bits for testing to try and find the problem and obviously left the comments there when I copied it over to the thread. The variables used are all valid in the context of where the function is being used. However, I have found the problem to have been where I using the getElementById() I needed to put the ids in ' ', ie getElementById('su_ff). That part of it is working fine now
  6. Could somebody please check my syntax in the below javascript function? I am not overly experienced with complex javascript so I have thrown this together based mainly on my knowledge of php. I am pretty sure the logic behind my function is right but I am unsure of the syntax. It is throwing up an error whenever I call this function. function selecter(click_ff,click_start,click_end,res) { //if (document.getElementById(su_ff).value == null) { // set form field values document.getElementById(su_ff).value = click_ff; document.getElementById(su_start).value = click_start; document.getElementById(su_end).value = click_end; } else if (document.getElementById(su_end).value - document.getElementById(su_start).value == res + 1) { // unshade previously selected cells // set form field values document.getElementById(su_ff).value = click_ff; document.getElementById(su_start).value = click_start; document.getElementById(su_end).value = click_end; } else if (click_ff != document.getElementById(su_ff).value) { // unshade the previously selected cell/s // set form field values document.getElementById(su_ff).value = click_ff; document.getElementById(su_start).value = click_start; document.getElementById(su_end).value = click_end; } else { if (click_start < document.getElementById(su_start).value) { // set form field values document.getElementById(su_start).value = click_start; } if (click_end > document.getElementById(su_end).value) { // ser form field values document.getElementById(su_end).value = click_end; } } // shade selected cells document.getElementById('_'+click_ff+'_'+click_start+'_'+click_end).style.backgroundColor = '#333333'; }
  7. I am pulling my hair out with this one! I am validating my page as XHTML 1.0 Strict and it keeps throwing up errors with my <input> tags. The validator says: document type does not allow element "input" here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre", "address", "fieldset", "ins", "del" start-tag The section of the script for the form is: <form id="status_updater" action="/eas/FF_WEEKLY.PHP?" method="get"> <input id="su_ff" name="su_ff" type="hidden" /> <input id="su_starttimestamp" name="su_starttimestamp" type="hidden" /> <input id="su_endtimestamp" name="su_endtimestamp" type="hidden" /> </form> Can anybody tell me what I need to do to get rid of the errors? The error is being displayed for each <input> tag in the form.
  8. Thanks for the alternative approaches offered. Maybe a little more detail about what I am trying to do will explain why I need to be able to do this and you can suggest the best approach. I would like to be able to display a list of information drawn from my database. The list will refresh periodically and update with any newly added records to the database. When a new item is added to the list, I would like to be able make the text flash to bring it to the attention of the user. There will be a button next to the new items which the user can use to acknowledge the new entry; once acknowledged, the list entry will no longer flash. I have googled scripts for flashing text and found a couple of approaches: one involving a css statement to set the text to blink but I believe this is not compatible with all browsers, nor does it give me the flexibility I am looking for in my styling; the second method was a javascript function which would run on page load and change the class of an element, however this function had to reference a specific element id. The approach I thought would be easiest would be to have a class set of, lets call it 'flash', and apply this class to any element that I want the text to flash. Then have a javascript function that would change the font colour parameter of this class every second, alternating between two colours. This changing the text colour of any element where the class has been applied. To do this, I need to be able to use javascript to reference the font-color property of a class and change it's value. Hope this makes sense and gives you a better idea of what I am trying to do. Maybe somebody will have an easier approach!?
  9. I would like to be able to change the style within a CSS class using JavaScript. For example, I have several blocks of text in my script, each block is styled using the class 'sometext'. The 'sometext' class is detailed in a seperate CSS file called 'stylesheet.css'. Amongst other things, lets say that font-color is set to be red within the class 'sometext'. I want to be able to write a JavaScript command which will change the font-color value to blue for the class 'sometext'. Changing this value should then effect the styling of the text for all elements with the class 'sometext'.
  10. Many thanks for your input - I think that array structure will be ideal for what I am trying to do so I will amend my approach to utilise this.
  11. Are you suggesting that instead of using: <?php $var1 = 'var1'; $var2 = 'var2'; $var3 = 'var3'; $temp = $var1 . '_' . $var2 . '_' . $var3; ${$temp} = 'new variable'; echo $var1_var2_var3; ?> I should use: <?php $var1 = 'var1'; $var2 = 'var2'; $var3 = 'var3'; ${$var1}[{$var2}][{$var3}] = 'new variable'; echo $var1['var2']['var3']; ?> This structure would be just as easy for me to use. Would the syntax I have used in this example work or is there a different way I would need to declare the values of the multi-dimensional array?
  12. The project that I am working on is rather complicated to explain but at the moment this is the easiest way for me to get my head around naming the variables and being able to recall them logically. There will be a large number of variables used in calaculations which all ultimately end up beind displayed on the page in a grid format. Once I have got my head around the script and getting it all working, I may be able to find an easier structure for naming the variables but at the moment, at least, this I think is my best option.
  13. Ah yes, I guess that would work! Create the name of the new variable as the value of a temporary variable and then use this to name the new variable. Many thanks, I will give that a go
  14. I have already got this much to work but I need the new variable name to contain the value of the original variable plus further text if that makes sense?
  15. In a script I am working on, I would like to be able to use the value of one variable to form part of the name of a new variable. For example, where the value of $x is 'text' I would like to be able to create a variable called $new_text. I have googled this but cannot find anyone who has done exactly this. I can get it to work in part like this: <?php $x = 'text'; ${$x} = 'value of new variable'; ?> this above script results in a new variable called $text however if I try the following code to have the value of the initial variable as just part of the name of the new variable, it does not work: <?php $x = 'text'; $new_{$x} = 'value of new variable'; ?> I would have liked this to create the new variable called $new_text but I get a parse error. Does anybody know how I can get this to work? Ultimately, I will want to be able to use two or more variable values to create the name of one new variable, ie: <?php $x = 'var1'; $y = 'var2'; $z = 'var3'; ${$x}_{$y}_{$z} = 'new variable value'; ?> which I would then like to result in a new variable which is called $var1_var2_var3.
  16. I have a mobile 3G dongle to enable mobile broadband access on my laptop. My question is whether I can interact with the using PHP to enable an SMS message to be sent from a PHP script?
  17. Don't panic guys! I've susssed it! I actually had it right in the first place but I made an entry error in my test database in one of the ID columns so it was not referencing properly!
  18. I have three tables... table 'transactions' which includes columns 'transactionID' and 'date' table 'analysis' which includes columns 'transactionID' and 'categoryID' table 'categories' which includes columns 'categoryID' and 'category' A very basic summary of this database is that the 'transactions' table will record individual financial transactions, with the 'analysis' table storing more detailed information about the breakdown of each transaction. The 'categories' table stores the category headings for analysis. For example there may be a record in the 'transactions' table recording a transaction for 100.00 and two further entries in the 'analysis' table breaking this down into two categories showing 50.00 for each. So for each entry in the 'transactions' table there will be atleast one entry in the 'analysis' table and each entry in the 'analysis' table will reference one entry in the 'categories' table. The query I am trying to build at the moment is to establish which of the 'categories' have been reference during a set time period. ie if I am building a table to display the transactions for a given time period, which entries from the 'categories' table do I need to use as headers for the table columns as I will not bother showing a column for a category which has not been used during that time period. So I need to query DISTINCT values of 'category' from the 'categories' table where their record has a 'categoryID' equal to 'categoryID' of all entries in the 'analysis' table which have a 'transactionID' equal to the 'transactionID' of all entries in the 'transactions' table which has a 'date' value between my set range. I am really struggling with the JOIN syntax here and which order to get the joins in to ensure I get the correct result. I have tried various combinations with LEFT JOINS and RIGHT JOINS but no joy!
  19. I have got IIS running on my laptop with PHP and MySQL so that I can test my scripts locally. I am currently working on a small project and I am half way through coding quite a hefty page but it is running really slowly. It can take around 20 seconds to load and I have still got quite a bit of coding to do on this same script. Just wondering if there is anything I can do to speed up the PHP on my server before I look at an alternative coding approach to get it running faster?
  20. The way that I am currently querying my database, I think, is slowing down the displaying of the requested page that I am working on. It is taking around 20 seconds to load! Inorder to display the data in the way I require it, I am running one query which is returning a set of data containing between 10 and 20 records. The result of this query contains some data to display on the page but for each record returned, I am also having to carry out a further query of the database to return several records of another table. The results of this query will return approx 100 records containing data to display. Like I have said, the page as I have coded it so far (which is by no means complete) is taking approximately 20 seconds to load. I am wondering whether there is a more efficient way of extracting the data from the database? I have tried to find some example scripts to produce what I am doing but I have had no success trying to find anything vaguely similar.
  21. Surely somebody must have done something similar to this before? Maybe I didn't explain it very well!?
  22. Hello All. I have posted an earlier question with no response but having found this forum, I think I may have posted it in the wrong place! I am inviting suggestions as to the best way to approach this application I am trying to produce. I have got an idea on how to approach it but the little of it I have done so far seems to be quite heavily coded and slow on execution. As a relative novice, I would imagine I have not come up with the best approach to this. What I need is an application that monitors the availability of resources. Lets say there are 20 individuals (these are the reources) whos availability at any particular time we will want to monitor. I want to be able to display a grid on the screen specific to a selected date. The first column of the grid on the left will list the 20 individuals' names. Forget the second column for a second. The remaining columns across the page will represent time units and default to 1 hour units, so there will be 24 columns, the first representing 0000hrs to 0100hrs, the next will represent 0100hrs to 0200hrs etc etc. Each square of the grid within the time unit columns will display whether the individual in the appropriate row is available. This will be illustrated by a code entered into the square. Back to the second column that we missed, this will contain the total number of hours the relevant individual is available during the current week. Remembering that the current grid is only showing the availability for a current day, this column will need to total up the number of squares available in the current pages row in addition to the appropriate data for the rest of the week (Mon - Sun). At the top of the grid, their will be an additional row which will contain a total showiing how many of the individuals are available during that time period. So the column representing the time unit 0000hrs to 0100hrs will have a an entry in the top row showing the total number of individuals available during 0000hrs to 0100hrs. What I need to know is what approach would be best to use. By this I mean what is the best way to structure a database to store this data so that it is most accessable to produce the grid I have explained. One thing that I think makes this slightly more complicated is that although the grid defaults to hourly units, I need to create an option that would display the grid with optional 15 minute or 30 minute time scales. So availability would need to be recorded in the database in 15 minute blocks (I think)!. I know this sounds quite complicated but please give it some consideration. I just need pointing in the right direction! Jut ask if you need any further information if I have not made it very clear.
  23. Thanks MJDAmato, that gives me something to start with OMIRION, what would be your preferred method of doing this instead of JavaScript? I'm all for making it easy on myself!
  24. I need a little inspiration to help me work out how best to achieve something on a site I am working on. So rather than trying to explain the complexities of what I am actually doing, here is a little challenege for you JavaScript boffins. This is a simplified version of what I need to achieve and any working results should point me in the right direction. The challenge is to be able to display a 10 by 10 square grid using a <table> to lay it out on the page. Each cell will just be empty but with a white background. The user should be able to select a number of squares on any indiviual row by first left clicking in the first square of the selection and then left clicking in the last square of the selection. As the user is selecting these squares, to show that they are selected, the first square will turn blue when it is clicked, and then the whole selection will turn blue when the second sqaure is clicked. Once some squares are selected, the user should be able to right click to display a menu box which will contain a list of colours. Upon clicking one of these colours from the list, the background of the selected squares will change to the selected colour and the selected squares will be come unselected. Hopefully this is a very simple little bit of coding to somebody who has a good knowledge of JavaScript!
  25. I would like to be able to create an array using the value of a variable extracted from my database. I have extracted some values from my database: $result = mysql_query($query); and I want to loop through the results creating a multi-dimensional array using one of the values from the database as a key within the array: while($row = mysql_fetch_array($result)) { $multi_array => array($row[key] => array(a => $row[a], b => $row[b].....)) } Where I have used $row[key] within the second level array I want the value stored in $row[key] to be used to name the array. Any offers? I am sure I have done this before but can not remember how and can not find any reference material.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.