Jump to content

doug007

Members
  • Posts

    62
  • Joined

  • Last visited

    Never

Posts posted by doug007

  1. ok this isn't working it errors out:

    Warning: preg_match() [function.preg-match]: Compilation failed: nothing to repeat at offset 1

    $pattern='/^?[^=]+=(.*)$/';
    			if(preg_match($pattern, "home", $matches)){
    
    					  //$this->page=$this->urlpage;
    					  var_dump($matches);
    }
    

  2. Hi Guys,

     

    I'm trying to close a window without getting the prompt.  i am using this code:

     

    function NoConfirm(){
    window.opener = top;
    window.close ();
    }
    window.onLoad = NoConfirm;
    </script>
    </head>
    <body onLoad="popup(); NoConfirm(); window.close();">
    [/code/

  3. Pardon? Don't follow...

     

    sorry adam my bad.  i found a way around this problem, but this leads me to another question?  is it possible to actualy edit the a popup window so it does not show the top part of the window and the borders, so say i have form on the popup i only want that to be visiable and nothoing else?

  4. Ahh. It's the hash in the 'href' causing the error. For example, go to:

     

    http://www.pat-burt.com/csspopup.html#test

     

    Clear the address bar and enter:

     

    javascript:alert(location.hash);

     

    Alerts '#test'. Click to open the popup then re-enter the javascript command into the address bar, nothing is returned. You need to re-think the way you're calling the pop up. I suggest:

     

    <a href="javascript:void(0);" onclick="popup('popUpDiv')">popup</a>

     

    Although I would recommend looking into replacing that with a JS-disabled friendly alternative.

     

    thats cool, but I want to remain on the same window and the page does not have reload, hence why we using #

  5. That's no pop up *window* script, it's a JS page-based pop up - never really know what to call them. That shouldn't alter the URL at all, unless, how are you calling this pop up? I reckon they may be using the <a href="#"... trick which is removing the hash. This would be much easier if there was a live version to take a look at?

     

    this is how i am calling it:

     

    <a href="#" onclick="popup('popUpDiv')">popup</a>

  6. thanks, the problem appears to be that the url is not sent over to the popup.  so how would i go about sending the url to the popup, how can i modify the js.  sadly i am not js guru....any help would really appriciated.

     

    thanks

  7. this is taken soo much hair of my head....but yeah lets see if someone here has come across something similar...

     

    cheers guys

    okay here i tested and it worked

     

    <script language="javascript" type="text/javascript">
    var strurl=window.location.href+"";
    var splitted=strurl.split("#");
    alert(splitted[1]);
    </script>
    

     

    but it does not work on the popup window. 

     

    initially the url is this:

    http://wtgforum-internal/index.php?action=calendar#

     

    when you click on a link to create the popup

    <a href="<?=$url?>" onclick="popup('popUpDiv')"><?=$title?></a>

     

    it creates a popup, then the url on the parent window chnages to this

    http://wtgforum-internal/index.php?action=calendar#222222

     

    and your script only prints out 'undefined' on the popup window.

     

    the js the creates the popup is here

    function toggle(div_id) {
    var el = document.getElementById(div_id);
    if ( el.style.display == 'none' ) {	el.style.display = 'block';}
    else {el.style.display = 'none';}
    }
    function blanket_size(popUpDivVar) {
    if (typeof window.innerWidth != 'undefined') {
    	viewportheight = window.innerHeight;
    } else {
    	viewportheight = document.documentElement.clientHeight;
    }
    if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
    	blanket_height = viewportheight;
    } else {
    	if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
    		blanket_height = document.body.parentNode.clientHeight;
    	} else {
    		blanket_height = document.body.parentNode.scrollHeight;
    	}
    }
    var blanket = document.getElementById('blanket');
    blanket.style.height = blanket_height + 'px';
    var popUpDiv = document.getElementById(popUpDivVar);
    popUpDiv_height=blanket_height/2-350;//150 is half popup's height
    popUpDiv.style.top = popUpDiv_height + 'px';
    }
    function window_pos(popUpDivVar) {
    if (typeof window.innerWidth != 'undefined') {
    	viewportwidth = window.innerHeight;
    } else {
    	viewportwidth = document.documentElement.clientHeight;
    }
    if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
    	window_width = viewportwidth;
    } else {
    	if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
    		window_width = document.body.parentNode.clientWidth;
    	} else {
    		window_width = document.body.parentNode.scrollWidth;
    	}
    }
    var popUpDiv = document.getElementById(popUpDivVar);
    window_width=window_width/2-150;//150 is half popup's width
    popUpDiv.style.left = window_width + 'px';
    }
    function popup(windowname) {
    blanket_size(windowname);
    window_pos(windowname);
    toggle('blanket');
    toggle(windowname);		
    }
    

  8. Hi Guys,

     

    I am desperatly seeking a solution to how I can grab the anything after # sign on a url.

     

    so given this url:

    http://wtgforum-internal/index.php?action=calendar#222222

     

    i want to grab everything after the # sign and input that into a input fields value?

     

    i have been playing aroung with windos.locationhash but this only gets me as far as the # sign.  so doing a document.write(windows.location.hash) only prints out everything upto #

     

    :confused:

    split a url by "#" and get the array of index 1

     

    how do i do this?

  9. Sorry, I actually missed the line where you mentioned location.hash before. This is odd. What browser are you using? Works fine for me in every browser I have (Firefox, Chrome, Safari, IE (even 6)).

     

    ok i see what the problem is now.  i am opening a popup window and the url changes from initialy being

     

    http://wtgforum-internal/index.php?action=calendar#

    to

    http://wtgforum-internal/index.php?action=calendar#222222

     

    so hence why it does not grab the #222222

     

    how can i fix this?

  10. Hi Guys,

     

    I am desperatly seeking a solution to how I can grab the anything after # sign on a url.

     

    so given this url:

    http://wtgforum-internal/index.php?action=calendar#222222

     

    i want to grab everything after the # sign and input that into a input fields value?

     

    i have been playing aroung with windos.locationhash but this only gets me as far as the # sign.  so doing a document.write(windows.location.hash) only prints out everything upto #

     

    :confused:

  11. Ok the problem with placing the echo statement outside the if statement now is that it echos this:

     

    > > > > > > > > > > > > > > > > > > > checked="checked"> checked="checked"> next to each checkbox that is checked, but does not check the actual checkbox.

     

  12. Nice... but I suspect that you will end up with two inputs for each checked checkbox.

     

    I think that what you are trying to do would be better achieved with a WHERE statement in your mysql.  The trouble will still be that you have two pieces of data that satisfy your if clause.

     

    $tag_desc_id = $row['tag_desc_id'];
    $user_info = $user_info[user_id];
    
    $query2 ="SELECT tag_id FROM tags_options
    WHERE tag_id='$tag_desc_id' AND user_id='$user_info'";
    
    $result2 = mysql_query($query2) or die(mysql_error());
    
    while ($row2 = mysql_fetch_array($result2)) 
    { 
         if(!empty($row2['tag_id']))
         {
              echo "<input name=\"c_options[$i]\" style=\"border-style: solid; border:0px solid; border-color: #FFFFFF\" type=\"checkbox\" border=\"0\" value=\"".$tag_desc_id."\" checked='checked' />";  
         }//end if
         else
         {
            echo "<input name=\"c_options[$i]\" style=\"border-style: solid; border:0px solid; border-color: #FFFFFF\" type=\"checkbox\" border=\"0\" value=\"".$tag_desc_id."\" />"; 
         }//end else 
    }//end while

     

    Ah, Sorry WolfRage.  I stand corrected.  This should work in that case.

     

    Scratch that.  It won't work.  Like WolfRage said... need more code.

     

    or just try adding

     

    else
    {
    //global $checked; 
    echo"<input name=\"c_options[$i]\" style=\"border-style: solid; border:0px solid; border-color: #FFFFFF\" type=\"checkbox\" border=\"0\" value=\"".$row['tag_desc_id']."\"";  
    echo "> </input>"; 
    }// end else

    after your if statement

     

    same problem as above.

     

    here is my entire code, its little long, but really would appriciate if anyone cared to look at it.

     

    function do_checkboxes($userid){
    global $profile_info,  $setting, $smarty_object, $user_info;;
    
    if(isset($_POST['set_options'])){
      
    if(!$_POST['c_options']==""){
      foreach($_POST['c_options'] as $key=>$value) {
         
           $tag_name=mysql_real_escape_string($_POST['tag_name'][$key]);
      $id=mysql_real_escape_string($value);
    		  		
    	$delete = "DELETE FROM tags_options where user_id = '".$user_info[user_id]."' and tag_id <> '".$id."'";
            $deleteSQL = mysql_query($delete) or die(mysql_error());
    	//echo  $deleteSQL.'<br />';
    }
    
    foreach($_POST['c_options'] as $key=>$value) {
      		$tag_name=mysql_real_escape_string($_POST['tag_name'][$key]);
       $id=mysql_real_escape_string($value);
    
    	$oaction = "INSERT INTO tags_options (tag_id, tag_name, user_id) 
                		VALUES('$id', '".$tag_name."', '".$user_info[user_id]."')";
    //	echo $oaction.'<br />';
    
            $optionsSQL = mysql_query($oaction) or die(mysql_error());
    
    	}
    	if($optionsSQL){
    		echo '<font color=red>Your options have been saved</font>';
    	}	
    }
    }
    
    $query ="SELECT 
    			tag_desc_id, 
    			tag_name,
    			parent_id
    	FROM 
    			tags_description 
    	ORDER BY tag_name ASC";
    
    
    
    
    $result = mysql_query($query);
    
    if (!$result){
    	echo mysql_error();
    }
    elseif(mysql_num_rows($result)<=0){
    	//echo "No entries";
    }else{
    
    echo "<table  border=\"0\"  cellspacing=\"0\" cellpadding=\"10\">";
    echo "<form method=\"post\">";
    
    $i=0;
    
    while ($row = mysql_fetch_array($result)) {
    
    $i++;
    $incr = ($incr == 3) ? 1 : $incr + 1; 
    
    if($incr == 1) echo "<tr>";
    
    echo "<td class=\"formcheckbox2\">";
    $query2 ='SELECT 
    				tag_options_id, 
    				tag_id,
    				tag_name,
    				user_id
    		FROM 
    			tags_options';
    		$result2 = mysql_query($query2);
    		if (!$result2){
    				echo mysql_error();
    			}
    
    echo"<input name=\"c_options[$i]\" style=\"border-style: solid; border:0px solid; border-color: #FFFFFF\" type=\"checkbox\" border=\"0\" value=\"".$row['tag_desc_id']."\"";
    $checked = '';  
    										while ($row2 = mysql_fetch_array($result2)) {
    										if($row2['tag_id'] == $row['tag_desc_id'] && $row2['user_id'] == $user_info[user_id]){
    											//global $checked;
    											$checked = 'checked="checked"';
    
    					echo " $checked> </input>";
    
    				}
    
    
    			}
    			echo"<input type=\"hidden\" name=\"tag_name[$i]\" value=\"".$row['tag_name']."\"></input>";
    
    
    				echo $row['tag_name'];	
    		echo "</td>";
    if($incr == 3) echo "</tr>";			
    
    
    }
    
    echo "<tr>";
    echo "<td>
    
    		<input type=\"hidden\" name=\"set_options\" value=\"set_options\">
    		<input name=\"GO\" type=\"submit\" id=\"GO\" value=\"Save Changes\" class=\"button\">";
    echo"</td>";
    echo "</tr>";
    echo "</form>";
    echo "</table>";
    
    	}
    }/*
    

     

  13. Hopefully I can redeem my self in Defeated's Eyes.

     <?php
    $query2 ='SELECT
    tag_options_id,
    tag_id,
    tag_name,
    user_id
    FROM
    tags_options';
    $result2 = mysql_query($query2);
    if (!$result){
    echo mysql_error();
    }
    while ($row2 = mysql_fetch_array($result2)) { 
    if($row2['tag_id'] == $row['tag_desc_id'] && $row2['user_id'] == $user_info[user_id]){
    //global $checked; 
    echo"<input name=\"c_options[$i]\" style=\"border-style: solid; border:0px solid; border-color: #FFFFFF\" type=\"checkbox\" border=\"0\" value=\"".$row['tag_desc_id']."\""; 
    $checked = "checked='checked'";  
    echo " $checked> </input>"; 
    }
    } 
    ?>

     

    thanks WolfRage, this works, but the type type=\"checkbox\" is no longer wokring?

     

  14. WolfRage made a mistake.  The echo statement is not the problem.  The problem is that the while loop is causing your echo statement to execute twice. The code you end up with in your html is then...

    <input name="c_options[$i]" style="border-style: solid; border:0px solid; border-color: #FFFFFF" type="checkbox" border="0" value="tag_desc_id" checked></input> checked></input>

     

    check it out in your source.

     

    this sounds possible, but how do i fix this?  i need while loop to only loop through what is checked and if checked mark each checkbox as checked?

     

    cheers

  15. You included that at the bottom of your script. If you do not want it then remove it, else if it should do something else then modify your echo statement appropriately.

    <?php
    $checked = 'checked'; 
    echo " $checked> </input>";
    ?>

     

    yes i need my while loop there, but what do you mean with modifying my echo statement appropriatley?

  16. Hi Guys,

     

    I have the below code that returns a checkbox as checked if it matches a certain condition. i have embaded the php into the html opening and closing tags like below, but whenever somthing is checked instead of making a checkbox just check it is aslo echoing this "checked> " next to the checkbox. does anyone please know what i am doing wrong?

    echo"<input name=\"c_options[$i]\" style=\"border-style: solid; border:0px solid; border-color: #FFFFFF\" type=\"checkbox\" border=\"0\" value=\"".$row['tag_desc_id']."\""; 
    $query2 ='SELECT
    tag_options_id,
    tag_id,
    tag_name,
    user_id
    FROM
    tags_options';
    $result2 = mysql_query($query2);
    if (!$result){
    echo mysql_error();
    }
    while ($row2 = mysql_fetch_array($result2)) { 
    if($row2['tag_id'] == $row['tag_desc_id'] && $row2['user_id'] == $user_info[user_id]){
    //global $checked; 
    $checked = 'checked'; 
    echo " $checked> </input>"; 
    }
    } 
    

     

×
×
  • 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.