Jump to content

scottybwoy

Members
  • Posts

    532
  • Joined

  • Last visited

    Never

Posts posted by scottybwoy

  1. Do you have to create a class to use object structure?

     

    I have a json file that I want to write to, but it likes to be fed objects.  My php script can make an array, but the syntax is different.  Let me give you some code :

    $modelId = $v['modelId'];
    $stockTotal = $stockArr['stockTotal'];
    $file = "models$cat";
    
    $modelId->stock = $stockTotal;
    
    $fnames = array($file => $modelId);
    array_push($models_stockArr, $fnames);
    

     

    So basically I have three bits of data here; $modelId, $stockTotal, and $file.  I want the original name of the object to be whatever the $modelId is, which then has a ->stock attribute, with the value of $stockTotal.  The $modelId objects then need to go into the $file array and then the $file arrays get pushed into the $models_stockArr.

     

    So it should be simple, but the php manual isn't that clear on objects without classes.  Can I just do something like

    $obj = new $modelId;

     

    Fatal error, guess you can't, any other ways around it?

  2. Do you have to create a class to use object structure?

     

    I have a json file that I want to write to, but it likes to be fed objects.  My php script can make an array, but the syntax is different.  Let me give you some code :

    $modelId = $v['modelId'];
    $stockTotal = $stockArr['stockTotal'];
    $file = "models$cat";
    
    $modelId->stock = $stockTotal;
    
    $fnames = array($file => $modelId);
    array_push($models_stockArr, $fnames);
    

     

    So basically I have three bits of data here; $modelId, $stockTotal, and $file.  I want the original name of the object to be whatever the $modelId is, which then has a ->stock attribute, with the value of $stockTotal.  The $modelId objects then need to go into the $file array and then the $file arrays get pushed into the $models_stockArr.

     

    So it should be simple, but the php manual isn't that clear on objects without classes.  Can I just do something like $obj = new $modelId;

     

    Fatal error, guess you can't, any other ways around it?

  3. Thanks for all your help.

     

    I sussed it out.  I was already using "dbTbls" instead of "this".  My problem was that I was creating the div and putting it in the page before putting the content in.  So I just changed the two lines around.  Like so :

    var par = document.getElementById("par");
    newDiv.innerHTML = dbTbls.value;
    par.appendChild(newDiv);
    

    Could this be because of the speed, i.e. the div is not fully generated before the value can be assigned.  Because on my other script with the ajax calls and php generation, it works the other way around?

  4. Hi Nightslr

     

    I have tried it in Firefox and it just works!  I installed the firebug plugin and it doesn't come up with any errors!

     

    However my issue is that this is for an intranet, where the users will all be using ie6 not firefox for it.

     

    I'm not particularly after speed, but mainly convenience and to advance my skills.  What I am doing is creating a custom query compiler for end users to form their own basic SQL Queries without having to learn the syntax.  That way they can access any data they want, without needing me.

     

    So far I have a select menu of tables, then that generates a a number of column select menu / select all.  Once the user works out how many fields they want to return it will draw that many select menu's with the column names in.  If I crack it I may post it here or give it to phpMyAdmin.  Thanks for your help so far.  I changed the line you said, but still returs the same error in Ie6.

  5. Hi All,

     

    Thanks for all your help and advice so far.  I have been playing around and been doing a few more bits and pieces and was hoping to make it as unobtrusive and transportable as poss.  As this is just a basic template for a bit of Ajax magic, I am not so sure if window.onload is the best way to go about it.

     

    Here's a little bit extra to show you where I am :

    <script type="text/javascript">
    
    window.onload = function() {
    var dbTbls = document.getElementById("dbTbls");
    // var selects = document.getElementsByTagName('select');
    
    dbTbls.onchange = function() {
      	var newDiv = document.createElement("div");
    	newDiv.setAttribute("id", "numRows");
    
    	var par = document.getElementById("par");
    	par.appendChild(newDiv);
    
    	document.getElementById("numRows").innerHTML = dbTbls.value;
    }
    }
    </script>
    <body>
    <p id="par">
    <select id="dbTbls">
    <option value="Hello World!">Hello World!</option>
    <option value="Hello Universe!">Hello Universe!</option>
    <option value="Hello Foo!">Hello Foo!</option>
    </select>
    </p>
    

     

    Now on my proper page, I will start of with one (php compiled) select menu.  As the user selects certain data it will build more options for the user on the fly.  I have this working with two so far, but would like to make the code more reusable.

     

    As you can see I commented out "var selects = document.getElementsByTagName('select');"  So you can see where I'm going.  Then I thought I could make a for loop to get all the id's, and build a loop of function calls using those id's.  But as they will be generated via ajax, I was wondering if this was possible and how I would go about it, and what would I need to change window.onload to?  Sorry I've not really done much javascript, so am great full for your assistance.

  6. I want it to take the data from the select box and present it in the Div below.

     

    I'm just trying to do the basis for an ajax call which will create another select menu of column fields based on a table that is selected.

     

    I have already got a select menu elsewhere that get the tables but am just putting this basic demo up to solve my issues.

     

    By the Way the error did come from Internet Explorer.

  7. Ok here's what I have so far

     

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <script type="text/javascript">
    
    function presentData(field) {
    var e = document.getElementById('numRows');
    e.innerHTML = document.getElementById(field).value;
    }
    
    </script>
    <body>
    
    <select onchange="presentData(dbTbls);" id="dbTbls">
    <option value="Hello World!">Hello World!</option>
    <option value="Hello Universe!">Hello Universe!</option>
    <option value="Hello Foo!">Hello Foo!</option>
    <br />
    <div id='numRows'></div>
    
    </body>
    </html>
    

     

    It gives me the error, "null is not an object, line 7 char 2".  Do I need any quotes or other syntax.  I think everything is being passed correctly.

  8. I'm trying to implement the onClick functionality shown here on my web page.  I tried just copying and pasting it directly as a model.  But it just doesn't work (will not copy the data).  I even copied the url into the same browser to see if all the settings were correct and it works fine on the w3schools page, but not mine.

     

    I'm using this doctype

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    

     

    And It's running in II6 Win 2k Server, and is being called in a php page.  But looking at the source, it appears just as the w3schools page.

     

    Any Ideas?  Thanks.

     

     

  9. you can try

    html { height:100% background:#C00; padding: 80px 0 30px 0; }
    #header { position: absolute; top: 0; height: 80px; width: 100%; background: F90; }
    #footer { position: absolute; bottom: 0; height: 30px; width: 100%; background: F90; }
    
    <body>
    <div id="header"> </div>
    <div id="footer"> </div>
    </body>
    

     

    Although I've not tested it.  Have a play around, it may be the way forward. Good luck.

  10. does your picture have transparency at the bottom, what browser are you using? divs can sometimes overlap, and your top-nav has a top padding of .3em try doing padding: 0 0 .3em 0;  It may even be better to drop that div and give the id to the ul.

     

    i.e

    <!-- top nav -->
            <ul id="top-nav">
                <li><a href="#">Link 1</a></li>
                <li><a href="#">Link 2</a></li>
                <li><a href="#">Link 3</a></li>
                <li><a href="#">Link 4</a></li>
                <li><a href="#">Link 5</a></li>
            </ul>
    

  11. float stays in-line with normal flow, but also gets converted to a block element.  Block elements generally don't sit next to each other unless you specify (which float does).  Normal flow means it will remain relative to the object that comes before it in the code (but sometimes that not the case with float:right;)  What I would suggest is for all you width declarations use %'s, even for margins and padding, use em for heights, this way it shouldn't cock up so much when changing screen resolution or text size.  Play around its the best way to learn, don't get too stressed, take a break.  Good luck

  12. This is precisely the point of z-index, but there are still some problems about how various browsers work them out, *annoyance*.  Look it up in google to find out more.

  13. Yo Yo ppl,

     

    I have designed a website, that is pure div layout and created a clean way (well I think its clean) to style my form elements.

     

    Problem is for another website its laid out via tables (OsCommerce site).  I thaught I could just integrate my css from a -> b and it would work.  So just like any other computer related action, its not the case.  It works fine in ff, but ie 6sp1 says no.  I found by disabling the css in ie, it displays much better.  Here's some code to give you a better picture.

    
    div.row {
      clear: both;
      height: 1%;
      padding: 0.4em 0; }
    div.row label {
      float: left;
      width: 35%;
      text-align: right;
      font-weight: bold; }
    div.row input, div.row select {
      float: right;
      width: 40%;
      margin-right: 20%;
      padding: 2px 0.5% 1px 0.5%;
      font-family: Verdana, Sans;
      font-size: 0.8em;
      color: #000080;
      border: solid 1px #3f547f; }
    

    And some html :

    <tr>
    		            <td width="49%" valign="top">
    		              <h3><?=HEADING_NEW_CUSTOMER?></h3>
    		              <p><?php echo TEXT_NEW_CUSTOMER . '<br /><br />' . TEXT_NEW_CUSTOMER_INTRODUCTION; ?></p>
    		              <div class="row" style="text-align:right; padding-right:10px;">
    		              	<?php echo '<a href="' . tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL') . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?>
    		              </div>
    			          </td>
    		            <td align='center' class="v_divider" align="absmiddle" width="2%"><?php tep_image(DIR_WS_IMAGES . 'pixel_trans.gif') ?></td>
    		            <td width="49%" valign="top">
    		            	<h3><?=HEADING_RETURNING_CUSTOMER?></h3>
    		              <p><?=TEXT_RETURNING_CUSTOMER?></p>
    		            	<div class="row">
    		          		  <label for='email_address'><?=ENTRY_EMAIL_ADDRESS?></label>
    		          		  <?=tep_draw_input_field('email_address')?>
    		            	</div>
    		          		<div class="row">
    		          			<label for='password'><?=ENTRY_PASSWORD?></label>
    		              	<?=tep_draw_password_field('password')?>
    		              </div>
    		              <div class="row smallText" style="text-align:center;">
    		              	<?php echo '<a href="' . tep_href_link(FILENAME_PASSWORD_FORGOTTEN, '', 'SSL') . '">' . TEXT_PASSWORD_FORGOTTEN . '</a>'; ?>
    		              </div>
    		              <div class="row" style="text-align:right;">
    		              	<?php echo tep_image_submit('button_login.gif', IMAGE_BUTTON_LOGIN, 'style="width:100px; border:0; margin-right:10px;"'); ?>
    		              </div>
    								</td>
    		          </tr>
    

     

    What is happening is (in ie6) is that the first <td> is all scrunched up small the third expands miles to the right (I'm not exaggerating when I say miles, its like 100 100%'s).  It works fine in ff and when the same css is used contained in divs or even framesets and forms.  Any idea on the dirrefernt behaviour between these elements and how I can get around it please.  P.S. It acts like this on every page I have input + labels laid out like so.

     

    Thanks for your help

  14. I have noticed that whether the directive is set in php.ini or not, it doesn't matter.  Searching all the files in my web directory for ini_set( returns 6 entries, none of them including session.bug_compat_42 or session.bug_compat_warn.

     

    Also the mod file that apache uses is c:/php448/php4apache2.dll is that what should be in my .htaccess?

     

    Thanks.

  15. At the moment they are both ON,  I have had them off before though at it didn't seem to make much difference.

     

    Funny thing is that they are ON for local level and master level, when in my .htaccess file I have :

     

    <IfModule mod_php4.c>
      php_value session.use_trans_sid		0
      php_value register_globals			1
      php_value magic_quotes_gpc	      	0
      php_value session.auto_start		0
    </IfModule>
    

     

    Does this mean that my apache is not configured correctly?

  16. Lol, thanks.  I posted there too, but I think this forum is much better.  If that error is just the OsCommerce message,  Surely there is a deeper explanation.  I have checked all those settings, but the message just won't go.  My .htaccess file does not interfere.  Any other ideas, or is it really incomprehensable unless you understand how OsCommerce works?

     

    Thanks anyway.

  17. Hi I know Register Globals is a no no.  However I am using OsCommerce, which is an open source e-commerce site.  Unfortunately it uses register globals.  This is not my issue though.  On my localhost Apache server, php v4.4.8 keeps Warning me :

     

    session_write_close() [function.session-write-close]: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in C:\Apache\Apache2\htdocs\klickshopping\includes\functions\sessions.php on line 106

     

    Concerning this function :

     

    <?php
    
      function tep_session_close() {
        if (PHP_VERSION >= '4.0.4') {
          return session_write_close();    // Line 106
        } elseif (function_exists('session_close')) {
          return session_close();
        }
      }
    
    ?>
    

     

    In my php.ini register globals is set to ON, but I think this is cocking up my navigation as it can't seem to find the files in the url.  (I am using a SEO URL mod) so would like to keep the code as is for the time being.  Anyone have any pointers / solutions.  Thanks for you time ;)

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