-
Posts
5,717 -
Joined
-
Last visited
-
Days Won
6
Everything posted by Adam
-
Ignoring the use of $GLOBALS for now, I'd use a multi-dimensional array for this: // source_id => phone number $GLOBALS['numbers'] = array( 0 => array('0844 000 3000'), 1 => array( '0844 000 0300' 'keywords' => array( 'test'=> '0844 000 0350', 'new'=> '0844 000 0351' ) ), 2 => array('0844 000 0301'), 3 => array('0844 000 0302'), ); Then where you check the "nid" exists within the numbers array, add in a conditional to check if the keyword is set and there's a matching index: if (array_key_exists($_SESSION['ct_source'], $numbers)) { if (!empty($_REQUEST['kw']) && array_key_exists($_REQUEST['kw'], $numbers[$_SESSION['ct_source']]['keywords'])) { return $numbers[$_SESSION['ct_source']]['keywords'][$_REQUEST['kw']]; } return $numbers[$_SESSION['ct_source']]; } The code, in all honesty, is very ugly. If you want help rewriting it and to get away from the use of $GLOBALS, I'm happy to help.
-
Is there an error?
-
"c%3==0" ? Is this some kind of formatting error from posting, or is that actually your code? Most likely that would trigger a syntax error (check the error console, in FF it's under "Tools" > Error Console"), which would prevent the rest of the code from working. Edit: by the way the yellow wasn't a good choice. I had to highlight it to read it - use tags in future.
-
Can you show the surrounding code? Most likely that's where the problem is.
-
You're passing the select object within the function parameters, so you don't need to reference the DOM path (document.form1.select.value) like you are doing. Just use the opt.value property within the function to get the value. By the way you're code would work if you moved the select element within the form tags (which you should move anyway to include them as part of the form), but as you're passing the object as I said, you shouldn't use the DOM path.
-
How do you link the JS and PHP; via an AJAX call or the result simply echoed straight into the JavaScript?
-
So you want to be able to return different numbers for specific keywords, where the "nid" also matches?
-
I don't understand your logic. Where is '0844 000 0350' supposed to come from?
-
multiple connections using mssql_connect()
Adam replied to manishtyagi83's topic in Microsoft SQL - MSSQL
Have you checked the error message with mssql_get_last_message? -
How can i stop propogation to ul/li list elements?
Adam replied to shortysbest's topic in Javascript Help
Can you show the load_notifications() function? -
I know what you mean. A possible solution would be to store the title within a global var as the page loads. Then whenever you update the page title, set it to the global var + the extra string. Quick example: var g_page_title; window.onload = function() { g_page_title = document.title; } function updateTitle(title) { document.title = g_page_title + title; }
-
Yeah, just modify the document.title property.
-
is there any way by which we can understand which submit button is clicked
Adam replied to bindiya's topic in Javascript Help
Just realised this is in the JS forum. How are you triggering the submit event? -
is there any way by which we can understand which submit button is clicked
Adam replied to bindiya's topic in Javascript Help
Assign the submit buttons different names, then just check which is set: <input type="submit" name="form1_submit_button"> <input type="submit" name="form2_submit_button"> if (isset($_POST['form1_submit_button'])) { // process } elseif (isset($_POST['form2_submit_button'])) { // process } -
To be honest, I'll help you soon as I hear a valid reason for an update every *second* - not being a dick, it's just teaching people bad habits. Nothing, requires an update every second, especially frames. You render the frame entirely useless because it updates ever second. Perhaps if you explained what it is you're trying to do ..?
-
document.getElementsByName to change font color not working
Adam replied to RLJ's topic in Javascript Help
document.getElementsByTagName returns an array, not an object. You need to use a for() loop to loop through each element it matches: var elements = document.getElementsByName("txt"); var length = elements.length; for (var i = 0; i < length; i++) { elements[i].style.color='red'; } -
You can use a JOIN to 'join' the two tables. I had to guess some of the table names/columns, but you should be able to work it out: select i.id , i.title , i.description , p.entry_id from items i join possessions p on (i.id = p.item_id) where p.user_id = {$id}
-
Firstly, why would you want to refresh the page every second? If it's absolutely necessary, and will run for long periods of time, then you may be better opening a persistent connection with mysql_pconnect.
-
Does the submit button get set to disabled=false?
-
I'd use a normal join here: select m.merchant_id , m.merchant_name , v.voucher_id , v.voucher_name from vouchers v join merchants m on (m.merchant_id = v.merchant_id) where m.merchant_name like '{$letter}%'
-
Search Engine Friendly urls for CMS without mod rewrite?
Adam replied to binarywebs's topic in Application Design
You could always resort to passing parameters through the 'PATH_INFO' server var: example.com/index.php/parent1/parent2/actual-page Just doesn't look as good. -
Yeah. To be honest there was too much ambiguity in the description of the problem before, so I just didn't attempt an answer.
-
MMDE - you can pass a value using a submit button, provided it's got a name attribute.
-
Try debugging the reutrn values with a print_r within the while loop.
-
If you're using PHP version > 5, you can use filter_var to validate an email: if (filter_var($email, FILTER_VALIDATE_URL)) { If < 5, just search around on Google for a regex to validate email addresses (just make sure it uses preg_match, not ereg). quote() is not a standard PHP function, at a guess I'd say you're referring to the PDO extension's quote() method.