|
maybe not.
what I would recommend instead then is breaking this up into its own example (but still full js and html) and working with it from there. I have found it best to isolate problems this way when the total solution has a lot of other "stuff" happening.
in debugging this my first assumption is that you javascript just isn't executing or isn't executing completely. after that I would assume that some sort of css rendering is interfering with what you are trying to do.
plus the other bonus in breaking it up into a small and complete solution is that you can post it back to a question forum when you have tried everything.
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
myHeight = window.screen.height;
myWidth = window.screen.width;
If you want to find only the usable area (space that remains after taskbar etc) use "availHeight" and "availWidth"
So you can have various CSS classes for the various screen resolutions and by checking user's resolution you can change them on the fly!
CSS:
.class1024 {
color : "green";
}
.class800 {
color : "blue";
}
JavaScript:
if(myWidth == 1024) {
elem.className='class1024';
}
else if (myWidth == 800) {
elem.className='class800';
}
Hope this helps!
-Shenbaga Murugan Paramasivapandian
I hate computers and I just mess them up with my code!
|
|
|
|
|
Hi there, I like your intention that you would like to manually change website size after knowing the user's screen dimensions, but hey! that is simply a waste of time and might make u write 1000s lines of code which might actually not work on every computer.
A properly designed website will at most resize itself when rendered by a browser. Mostly all you need is to set the width of the outter content (div) to say: width:960px;
Don't set the height, let the browser decide how much your web page will grow downwards.
Honestly speaking, it's messy to rely on your clients resolution to determin your page display layout.
In my designing, i just design one site with one set dimension and that's it! the rest will sort itself on client-side without any javascript/jQuery involved.
Happy designing,
Morgs
|
|
|
|
|
Hello All, I have a thumbnail image inside of a table cell that when clicked displays an image that is much larger than the table cell. The problem I am having is that I can not make the larger image display on its own layer so that it hovers above all other page elements and does not stretch the table cell that is holding it. I have tried changing the Z-indez but it does not help. Please point me in the right direction, thanks in advance for your help.
-- modified 16-Oct-11 2:12am.
|
|
|
|
|
This is commonly called a "lightbox" or "dialog".
jQuery UI Dialog does this (note that their website seems to be having trouble right now loading CSS and images). I used Firebug to inspect it and they appear to be using the z-index approach. I recommend using Firebug (or a similar tool, such as Developer Tools in IE or Chrome) to inspect the z-index and ensure the other elements on the page do not have greater z-indexes. Also make sure you aren't making silly mistakes, such as putting the z-index in the class attribute rather than the style attribute (I just make that mistake today) or setting the property incorrectly through JavaScript. Firebug should help with that too.
If you are still having troubles, come back here and 1) show some simple sample code to replicate the issue and 2) explain what exactly you mean by "it does not help". Any additional information would be useful (e.g., the browser you are using, some screenshots).
Somebody in an online forum wrote: INTJs never really joke. They make a point. The joke is just a gift wrapper.
|
|
|
|
|
Hi and thank you so much for replying. I am trying out your suggestion of using Firebug to determine the z-index of other page elements to make sure they are not greater than the z-index of the image I am trying to display. If I'm still unsuccessful I will definitely ask for help.
|
|
|
|
|
I want to read the content of existing excel file using java script, and then download the file with those contents.
Thanks.
|
|
|
|
|
if the file is located on the server then you should be able to use AJAX and issue a GET request to retrieve the file from the server.
are you using jQuery?? I seem to recall $.ajax({...}) having an example of how to do this.
if you can offer some more details of what you are trying to do and where the file is located that would help a bit more.
|
|
|
|
|
Actually i have some data in an excel file.
I have read the file easily in java language.
Now on web, it seems bit difficult for me to do this.I have not been involved in web programming for long time.
Just to retrieve the data from excel file placed locally in drive, in some alert or by any means.
Then that retrieved contents will be used for further processing.
Can you please guide.
Thanks for any help.
|
|
|
|
|
loading local files with javascript is a no no and I don't believe most browsers will support it. I seem to recall you being able to do it with older version IE using ActiveXObject and loading the Msxml2.DOMDocument control.
You will have to google to get more info on how to do that.
If the file is local then why not have a working version loaded to the server where you can parse it and use ajax calls to retrieve and update?
there is always more than one way to skin a cat.
|
|
|
|
|
|
|
Hi all...
Im trying to move selected items from various drop down lists into a javascript based table. Below is an example of the code I currently have. So I select an item from a list:
<select name="Activity">
<?php
$sql = "SELECT Status FROM Activity";
$rs = mysql_query($sql) or trigger_error(mysql_error() . " unable to run query.");
echo "<option></option>";
while($row = mysql_fetch_assoc($rs))
{
echo "<option value=\"".$row['Activity']."\">".$row['Status']."</option>\n ";
}
?>
</select>
and then I want to move the selected item into its relevant field location within a table as per:
<button onclick='addRow();'>Add to Table</button>
<script type='text/javascript'>
function addRow(){
var myTable = document.getElementById('myTable').getElementsByTagName('TBODY')[0];
var tr = document.createElement('TR');
var td1 = document.createElement('TD');
td1.innerHTML = '<input class="name" />';
var td2 = document.createElement('TD');
td2.innerHTML = '<input class="date" />';
var td3 = document.createElement('TD');
td3.innerHTML = '<input class="name" />';
var td4 = document.createElement('TD');
td4.innerHTML = '<input class="hours" />';
var td5 = document.createElement('TD');
td5.innerHTML = '<input class="name" />';
var td6 = document.createElement('TD');
td6.innerHTML = '<input class="name" />';
var td7 = document.createElement('TD');
td7.innerHTML = '<input class="description" />';
tr.appendChild(td1);
tr.appendChild(td2);
tr.appendChild(td3);
tr.appendChild(td4);
tr.appendChild(td5);
tr.appendChild(td6);
tr.appendChild(td7);
myTable.appendChild(tr);
}
</script>
<table id='myTable'>
<thead>
<tr>
<td>Name</td>
<td>Date</td>
<td>Project</td>
<td>Hours</td>
<td>Department</td>
<td>Activity</td>
<td>Description</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
Any ideas how I do it please? Thanks
|
|
|
|
|
looks like your table is being populated with a new row each time the button is clicked. so your javascript code is working fine.
are you asking how to select some value from the drop down and put that into the table when the button is clicked??
|
|
|
|
|
Hi Dennis,
Thats correct Im trying to populate the field within the table from the drop down list. I think I may be going about it wrong as I then want to be able to submit that data to a server and that wont work under the current configuration.
|
|
|
|
|
Hi all..
Im trying to create and populate a dynamic table where by a user has a 4 lists which are populated from a php/mysql form. I would like then the user to be able to add thier selections to the javascript table. The table would grow as the user add more selections.
Does this make sense??
Thanks
|
|
|
|
|
Please explain what a "javascript table" would be please. I've never heard of that phrase before.
Thanks!
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
|
|
|
|
|
Well as I understand it and I am new to javascript so forgive me. A javascript table is a table which is made using javascript code? I have my data selected from a drop down list and I am trying to capture it in a table before it gets submitted.
Thanks
|
|
|
|
|
I see, you want to add table rows to a table then, if I understand you correctly?
Does that table have a fixed amount of columns or will these also be dynamic?
What is your vision of the user selecting the values from the lists into the columns?
Is it possible that the four lists correspond to four columns and after selecting a value from each of the lists they are transfered into a new dynamically created row in your table by pressing a button "Add selections"?
Regards,
—MRB
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
|
|
|
|
|
I've composed this small example utilizing jQuery. I've spared my self the trouble of adding the part where the user can select entries from a drop down list as this does not seem to be your problem. This solution only concentrates on how elements can be added dynamically by using jQuery. Enjoy!
<html>
<title>Add row to a table</title>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript">
function addRow(column1, column2, column3, column4)
{
$('#theTable > tbody:last').append('<tr><td>' + column1 + '</td><td>' + column2 + '</td><td>' + column3 + '</td><td>' + column4 + '</td></tr>');
}
</script>
</head>
<body>
<h3>Add row to a table</h3>
<input type="button" value="Add a row!" onclick="addRow('This', 'is', 'a', 'test');"></br>
<table id="theTable" border="yes">
<tbody>
</tbody>
</table>
</body>
</html>
Regards,
—MRB
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
|
|
|
|
|
OK, it's Monday morning, and instead of doing useful work, I am trying to answer this question:
Most of the JavaScript naming conventions I have seen around the web say that most variable and function names should start with a lower case letter. Why is that?
My other signature is witty and insightful.
|
|
|
|
|
Here. Probably because the JavaScript libraries use camel case (lower initial letter for variable and function names). Case is especially important in JavaScript, as the only way to differentiate a class and a function may be the case (as classes, in the form they are usually implemented, are functions).
Somebody in an online forum wrote: INTJs never really joke. They make a point. The joke is just a gift wrapper.
|
|
|
|
|
Because it's C-based and that is the usual standard for C-based languages.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
Yes, but then how can you tell at a glance if something is a variable or a function? Other than parends after the function name. I had been using a convention of upper camel case for local variables and upper camel case for functions. But my co-workers tell me that I'm the only one in North America to do it like that. They also tell me my mom dresses me funny, too.
My other signature is witty and insightful.
|
|
|
|
|
by reading the code. Context is king.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|