Jump to content

radalin

Members
  • Posts

    179
  • Joined

  • Last visited

    Never

Posts posted by radalin

  1. Hi,

    I'm trying to give a cinematic effect on my site. I have two different divs. After a period of time, I want that the div that is seen fades and the unseen div starts to show up at the same place of the currently fading div. I googled around a while, found some fade div codes but they confused me a little too. I'm starting to think what happens If I increase the number of divs. Can you point me somewhere or give some clues on how to do it. I have lost my way. The code I tried is below, I tried to edit this but I was unable. I had tried first to fade and show divs and then locate them on the same place, but I was unable to pass the first step :) I appreciate your help

    Thank you for your time.

     

     

    <html>
    <head>
    <title>X-Browser Fade In/Out</title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    /* filter style is necessary to register object with ActiveX (only works with block elements
    that have height or position assigned) */
    #out1{
    border:4px dashed;
    width:200px;
    padding:0;
    }
    #div1{
    font:1.2em Verdana,sans-serif;
    height:100px;
    background:#cdd;
    padding:1em;
    filter:progid:DXImageTransform.Microsoft.Alpha(opacity=100);
    }
    #out2{
    border:4px dashed;
    width:200px;
    padding:0;
    }
    #div2{
    font:1.2em Verdana,sans-serif;
    height:100px;
    background:#cdd;
    padding:1em;
    filter:progid:DXImageTransform.Microsoft.Alpha(opacity=100);
    }
    #out3{
    border:4px dashed;
    width:200px;
    padding:0;
    }
    #div3{
    font:1.2em Verdana,sans-serif;
    height:100px;
    background:#cdd;
    padding:1em;
    filter:progid:DXImageTransform.Microsoft.Alpha(opacity=100);
    }
    </style>
    <script type="text/javascript">
    // op_val sets initial opacity value; fad_var the fade value or amount, bigger is faster;
    // fad_rat sets the rate, smaller is faster; fad_dir is direction of fade
    // different numbers are used to get similar effects on different browsers
    var op_val,fad_var,fad_rat,fad_dir,top_val,bot_val;
    if(document.defaultView){
    // for standards-compliant browsers
    op_val=1; // applied opacity setting
    top_val=1; // top opacity setting
    bot_val=0; // lowest opacity setting
    fad_var=.02;
    fad_rat=20;
    }else{
    // for IE
    op_val=100;
    top_val=100;
    bot_val=0;
    fad_var=10;
    fad_rat=50;
    }
    function fader(){
    op_val=op_val+(fad_var*fad_dir);
    // the following ternary conditional should appear on one line
    document.defaultView ? document.getElementById('div1').style.opacity=op_val : div1.filters.item("DXImageTransform.Microsoft.Alpha").opacity=op_val;
    if((fad_dir==-1&&op_val<=bot_val)||(fad_dir==1&&op_val>=top_val))clearInterval(fadeIntr);
    }
    
    function setFade(){
    fad_dir = (op_val >= top_val ? -1 : 1) ; //Will we fade or show...
    if(typeof fadeIntr!='undefined')clearInterval(fadeIntr); // in case someone makes multiple clicks
    fadeIntr=setInterval(fader,fad_rat);
    }
    
    
    //Current Div holder
    totalCount = 3 ;
    currentDiv = 1 ;
    
    function Next() {
    //Let's fade the current div and show the next one...
    setFade();
    changeCurrent(1);
    setFade();
    }
    
    function Prev() {
    //Let's fade the current div and show the previous one...
    setFade();
    changeCurrent(-1);
    setFade();
    }
    
    function Show(divNum) {
    div = document.getElementById('div'+divNum);
    op_val=op_val+(fad_var*1);
    document.defaultView ? div.style.opacity=op_val : div1.filters.item("DXImageTransform.Microsoft.Alpha").opacity=op_val;
    if( fad_dir == 1 && op_val >= top_val ) clearInterval(fadeIntr);
    }
    
    function Fade(divNum) {
    div = document.getElementById('div'+divNum);
    op_val=op_val+(fad_var*1);
    document.defaultView ? div.style.opacity=op_val : div1.filters.item("DXImageTransform.Microsoft.Alpha").opacity=op_val;
    if( fad_dir==-1&&op_val<=bot_val ) clearInterval(fadeIntr);
    }
    
    function changeCurrent(num) {
    currentDiv += num ;
    if ( currentDiv == 0 )			currentDiv = totalCount;
    if ( currentDiv > totalCount ) 	currentDiv = 1 ;
    }
    
    </script>
    </head>
    <body>
    <table>
    <tr>
    <td>
    	<div id="out1">
    	<div id="div1" onclick="setFade();">
    
    	<p>
    	click on div to alter opacity property
    	</p>
    	</div>
    	</div>
    </td>
    	<td>
    	<div id="out2">
    	<div id="div2" onclick="setFade();">
    
    	<p>
    	click on div to alter opacity property
    	</p>
    	</div>
    	</div>
    </td>
    </td>
    	<td>
    	<div id="out3">
    	<div id="div3" onclick="setFade();">
    
    	<p>
    	click on div to alter opacity property
    	</p>
    	</div>
    	</div>
    </td>
    </tr>
    </table>
    <input type="button" id="btn_prev" value="Previous" onclick="Prev();" />
    <input type="button" id="btn_next" value="Next" onclick="Next();" />
    </body>
    </html>
    

  2. I have checked that for a while, this code works flawlessly in my FF. I don't know what is different by the way

     

    
    function addRoomBox(count) {
    if ( document.getElementById('room_count') >= 20 ) {
    	return false ;
    }
    if ( document.getElementById('room_count').value == count ) {
    	document.getElementById('room_count').value++ ;
    	box = document.getElementById('newboxspan') ;
    	box.innerHTML += '<br /><br /><input name="room_desc_' + count + '" type="text" id="room_desc_' + count + '" size="15" onFocus="addRoomBox(' + (count+1) + ');" /> / ';
    }
    }
    
    

     

    and the html part is like:

     

    
    <input type="hidden" name="room_count" id="room_count" value="1" />
    <input name="room_desc_0" type="text" id="room_desc_0" size="15" onFocus="addRoomBox(1);" /> /
    <span id="newboxspan"></span>
    
    

     

    Hope this helps....

  3. Well honestly as a PHP developer for a long time I enjoy working on PHP. Sometimes I hate it because the language is not as functional as the .net framework but sometimes I admire it because it's very easy to do something.

     

    The thing is MS is the dominent company in software, Most of the companies uses windows environement for their desktop! So if you want to get a job learn .Net. I do not say just ASP.Net, I say .Net. The thing is ASP.Net is not a language anyway!! It's just a common name for MS based web applications. You can use C#,VB.Net or Visual C++ to write and ASP.Net site! An also by learning .Net you may be able to write desktop applications too (which I believe are mostly useless...)

     

    Another thing is the Visual Studio. Even with it's bugs and other things it's the best IDE I have ever used! If PHP had such an IDE, with it's easy syntax everyone would be able to write simple dynamic sites.

     

    Do not get me wrong, I enjoy writing php codes, even I think that JSP is a far more better language then both ASP.Net and PHP, I still use PHP.

     

    I agree that if you get the idea on how to write a program, it doesnt matter which language you use. You may use PHP if you come from C++ legacy or JSP if you are familiar with Java or ASP.Net if you "like" MS.

     

    For the support, most of the open source communities give you a great support but MS side is good to. Check the msdn.microsoft.com, it's forums are pretty good at support about all of the MS products, they are quite fast too.

     

    What I'm trying to say is, try all of them. Not just ASP.Net or PHP but also ColdFusion and JSP, all of them are doing mostly the same things and then use the one which suits you best. If you get the idea about programming, it's no matter which language you use, you will absolutely get a job!,

     

    Just Calling to Zend take a good exampla of Sun Creator and Visual Studio 2005!!!!!!!!!!! :)

  4. The problem is while adding the text with innerHTML js does not take the modified files by user. It takes the file created on the loading of the page. Try adding a value="aaa" to the first box. While adding new boxes value returns to "aaa". But It works perfectly on IE but not at FF or Opera. I'm not sure how to solve this and it's 4 AM herei I got to sleep. I will look up later.

  5. I forgot to add function before addbox.

     

    Here is the tested and working code:

    <html>
    <head>
    <script language="javascript">
    var boxnum = 1 ;
    function addBox(num) {
    if (num==boxnum && boxnum < 20 ) {
    	boxnum++;
    	document.getElementById('boxes').innerHTML += "<br><input type=\"text\" name=\"box_" + boxnum + "\" onFocus=\"addBox(" + boxnum + ")\">";
    }
    }
    </script>
    </head>
    <body>
    
    <span id="boxes">
    <input type="text" name="box_1" onfocus="addBox(1);">
    </span>
    </body>
    </html>
    

     

    Just a hint about these kind of boxes. Put an end to them. You may not want a bad intended user to add houndred perhaps thousands of boxes! I added a control. It will not create more then 19 boxes. You can change the count or even disable that control

  6. How about something lke this:

     

    //HTML
    <span id="boxes"><input type="text" name="box_1" onFocus="addBox(1)" /></span>
    
    //JS
    var boxnum = 1 ;
    addBox(num) {
    if ( num == boxnum ){
    	boxnum++;
    	document.getElementById('boxes').innerHTML += '<br /><input type="text" onFocus="addBox(' + boxnum +');" name="box_' + boxnum + '" /> '
    }
    }
    

     

    No need to button or something. When textbox get the focus another box will reapper each time the last box will be focused another box will be added. Hope that helps

  7. You're right that when someone disables js, then your work is meaningless. But most of the users do not even know how to disable js or they do not care.

     

    I really love to use js in my web applications. Mostly for validations (I also write server side validations) and other things which increase the usability of my work. Like changing the color of a table when mouse comes over it, or hide and show some divs.

     

    For next generation sites which uses AJAX you have to write js anyway. Even there are some frameworks for the js part, I mostly write them. If you enjoy writing code like me, you also write js too :)

     

    But there isn't a good code editor for javascript. Most of them are not good enough. But anyway you should really try to write js. It creates a different in your site. As it works on the client side, it may give the user a better experience on the site.

  8. set a cookie on the client side like $_COOKIE['session_id'] or use a server side cookie (also called as session) $_SESSION['session_id']. Until you use session_unregister() function or the user do not close the browser $_SESSION is kept, if you use cookies then it will last till they expire.
  9. [code]
    session_start();
    echo $_SESSION['SID'] ; //echo no1
    if ( ! $_SESSION['SID'] )
    {
    $_SESSION['SID'] = md5( uniqid(rand(),1) );

    setSession( $_SESSION['SID'] ) ;
    }
    echo $_SESSION['SID'] ; //echo no2
    [/code]

    and the setsession function is

    [code]
    function setSession($sid = "")
    {
    if ($sid == "")
    {
    $_SESSION['SID'] = md5( uniqid(rand(),1) ) ;
    $sid = $_SESSION['SID'] ;
    }

    $this->db->connect() ;

    if (MDB2::isError($this->db))
    die($this->db->getMessage());

    $query = "SELECT session_id FROM sessions WHERE session_id = '" . $sid ."' ";

    $result = $this->db->queryOne($query);

    if (MDB2::isError($result))
    die($result->getMessage());


    //If this sid is previously set before then we have already have a value
    //for that user...
    if ( $result == $sid )
    return 0 ;

    //And if such sid does not exists
    $query = "INSERT INTO sessions (session_id,session_start,session_last_activity_date,session_ip,session_logged_in,user_id) VALUES ('$sid','" . date('m-d-Y H:i:s') ."','" . date('m-d-Y H:i:s') ."','". $_SERVER['REMOTE_ADDR'] ."','-1','-1')";

    $this->db->_doQuery($query);

    if ( MDB2::isError($this->db) )
    die($this->db->getMessage());

    $this->db->disconnect() ;

    return 1 ;
    }
    [/code]

    The problem is at echos. While first one does not print anything the second one does. (I assume you already entered to the site and clicked a few links.). setSession() function is called and then a new session id created. As the session id changes all the time, I can't reach to the right session row. I wonder why the session variables are lost.
  10. Hi,
    I'm using session variables for my member system. I got a session id which is kept as a session variable then have a session table etc. I get user info throught this session id. But the thing is in my local, session variables not saved! They are lost and every time I refresh the page they are recreated. There is a check, if there is no session then create a one, else use the existing one. I should be missing something in the php.ini or something I'm not sure about it.

    Any idea why can this happen? I have wamp 1.6.4 installed on my computer with Mysql 5 and PHP 5 options.

    Thank you for your time
  11. What is the error code? And also instead of DB you should use MDB2. it's like an newer version of DB and it's recommended. If the error is something about DB:Error then you should check the validity of your connection string. Try echoing it and look if anything is wrong
  12. while divs are much better ways. You could do something:

    [code]
    function toBox(field)
    {
        field.innerHTML = "<input type='file' name='send'>";
    }
    <span onClick="toBox(this)" id="field">Click here to view the file upload box</span>
    [/code]

    Something like this will work. But try hiding and showing divs.
  13. Hi,

    I have a problem with a select box. I have created two select boxes and then two buttons with add and remove functions. The thing is my function works flawless in FF and Opera but it doesn't in IE. Instead of removing selected option it removes all of the select box.

    [code]
    function addinfo(from,to)
    {
    var i = from.selectedIndex ;

    var myOption = document.createElement("OPTION") ;

    myOption.value = from.item(i).value ;
    myOption.text = from.item(i).text ;

    to.options.add(myOption) ;

    from.remove(i) ;

    }
    [/code]

    Here is the function. It takes two select boxes as arguments. There is something that I miss, but can't see it.
  14. I have question about javascript and array system. I'm using javascript in my web site and I would like to enable a language selection on it. I'm using language options from php side. an associative array, containing values like $lang["Hello"] => "Hello", and this goes on.

    Is there a way to do this with javascript? I mean is there a such an assosiative array option in javascript (which I do not think it's possible.). I have intended to use a getLang function which takes an argument about lang and with switch statements it returns the right value. Well that's ok but it will take a lot of time if I have thousand cases. Any idea is welcome.

    Thanks...
  15. well there are lots of mods preventing to be hacked. Cracker Tracker, phpBB Security and most of them prevent them to be hacked easily. A good hacker will not waste his time on cracking your board which will take more then 5 mins. And also for a script kiddie will get hard and hard on cracking a board installed with these mods (like phpbb security changes admin prefix and adds a .htacces restiriction to admin folder it adds a totaly new password to crack)

    Well but yes if you have an existing board running, you will encounter a lots of problems on passing it to phpbb. even it has some issues with passing from one phpbb to another too.
  16. what about tyring to install some mods to the phpbb like simple sub forums by which you will create a forum for each school and it will have same subforums but they will belong to that school. It's easy to moderate with group permissions too. You could add something while registering choosing their school and class and according to that, you can sign them to groups which will allow them to enter that forums.
  17. TOP was an mssql 2005 syntax. So it wont work on mysql.

    Even if there is a sql standart, most of the companies add their own features on them to be selected more. But above some expections like this, the sql syntax is the same.
  18. instead of hiding, try adding disabled on your submit button. Which will completely disable it.

    <input type="submit" value="Send" disabled />

    But it wont prevent someone to submit the form I think. With javascript injection something like

    javascript:void( document.myForm.submit(); )

    should submit your form I think. But I'm not sure. Try it on your browser if it works or not if you put disable on the submit button or even if you hide it.
×
×
  • 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.