Jump to content

jesh

Members
  • Posts

    2,293
  • Joined

  • Last visited

Everything posted by jesh

  1. That's what the window.onload is for. Alternatively, you can try this:<body onload="document.getElementById("mytextarea").focus();"> I tend to have more success using window.onload however.
  2. jesh

    Colour

    Just to throw in some more information - the "hash" code is in hexadecimal (values ranging from 00 to FF) whereas the RGB values are in decimal (values ranging from 0 to 255). They use different numerical systems.Check out the wikipedia article if you're interested: http://www.wikipedia.org/wiki/Hexadecimal
  3. In javascript, java, and C#, you'd use a try/catch(/finally) block. It'd look something like this:try{ // do some code here that may cause an error}catch(Exception e){ // handle the exception (error) here.} Perhaps there's something like that in VB as well.EDIT: Found this link: http://msdn2.microsoft.com/en-us/library/f...6tz(VS.80).aspx
  4. It may be because images are inline elements. When you float an element, the DOM converts the image to a block level element and then sets it floating off to the left (or right). If you have an image that is not floating, you might try setting the display for the element to "block" in the CSS to get rid of that white space.
  5. Check out focus(). window.onload = function() { document.getElementById("mytextarea").focus(); }
  6. I've never tried this, but it should work. First, you'd have to have a way to get access to the element. Typically, the easiest way is to assign an ID to it: <embed id="myembed" src="" autostart=false loop=false width="100%" height="45" name="radiosound"> Once you've done that, you can get at it using the getElementById() method on the document: var embed = document.getElementById("myembed");embed.src = "http://www.mysite.com/myfile.swf";embed.width = "100%";embed.height = "45";// etc.
  7. Same for me. I ran into the same problem when I was first learning div-based layouts - tables were just so much easier and no matter what I tried, I could never get the divs to look like the tables. I just had to give up and use tables. Six months later (maybe it was a year), another project comes around and div-based layout just sort of clicked for me so I gave it a shot and it worked brilliantly. I just needed to take a break and before I realized it, I understood how div-based layouts work.The same goes, with me, for almost all projects that I encounter - whether that's writing code, building a layout, gardening - that if I don't totally understand something right away, and if I'm not able to understand it after a few days of intense studying, I'll walk away from it and work on one of the hundred other projects that I have going on. Then, sometime later, when I go back to the project that stymied me,nine times out of ten I'm able to understand it.
  8. It looks like you might have used a LinkButton control in .NET to generate your links on the page. LinkButtons post back to the server just like regular Buttons will - using client-side javascript to run a function like __doPostBack();. If you would rather have a hyperlink, you might try using a HyperLink control instead. <asp:HyperLink id="FashionLink" runat="server" /> Then, in the code behind, you can set the URL for that link using the NavigateUrl property: FashionLink.NavigateUrl = "http://www.mysite.com/fashion.html"; // you can get this value from the database...
  9. When I was first learning .NET, I would always declare the controls that were being used on my pages in the code behinds - just like your C# example shows. If my page were: <%@ Page Language="C#" CodeFile="xsltGolfer.aspx.cs" Inherits="TestBed.Chapter7.XsltGolfer" Debug="True" %><html><body><asp:Button id="btnSubmit" Text="Get Golfer!" runat="server /></body></html> My code behind would also declare that btn: public class XsltGolfer : System.Web.UI.Page { protected System.Web.UI.WebControls.Button btnSubmit; However, as I get more comfortable developing .NET projects, I am realizing that Visual Studio (I assume the same with the Express versions) writes a lot of code that isn't strictly necessary. I have found that I don't need to declare my controls in the code behind file because they have already been declared in the aspx page.You might try modifying your VB from this: Public Class XsltGolfer Inherits System.Web.UI.Page Protected btnSubmit As System.Web.UI.WebControls.Button Protected pnlSelectGolfer As System.Web.UI.WebControls.Panel Protected pnlTransformation As System.Web.UI.WebControls.Panel Protected ddGolferName As System.Web.UI.WebControls.DropDownList Protected lnkBack As System.Web.UI.WebControls.LinkButton Protected divTransformation As System.Web.UI.HtmlControls.HtmlGenericControl Private xmlPath As String Public Sub New() AddHandler Page.Init, AddressOf Page_Init End Sub To this: Public Class XsltGolfer Inherits System.Web.UI.Page Private xmlPath As String Public Sub New() AddHandler Page.Init, AddressOf Page_Init End Sub I know it isn't necessary to declare those controls in both places - perhaps it isn't even correct to do so in VB and this may be the cause of your problems - and you will still be able to access the controls in the code behind.I hope this helps!
  10. jesh

    easy inner join

    SELECT orders.idOrder, orders.idProduct, orders.idUser, users.userNameFROM orders INNER JOIN users ON orders.idUser = users.idUser
  11. Just found this in the XML DOM tutorial. I believe it may answer your question perfectly:http://www.w3schools.com/xml/tryit.asp?fil...httprequest_js4
  12. OK, XML gurus, I just noticed in XHTML and using the XML DOM that the following is true (in Firefox).This td element contains 5 child elements - 2 ELEMENT_NODEs and 3 TEXT_NODEs: <td> <a href="#">link</a> <img src="" /></td> Whereas this td element contains only two elements - 2 ELEMENT_NODEs: <td><a href="#">link</a><img src="" /></td> Is this true of all XML documents? Does this XML document: <node> <node /> <node /></node> Contain 60% more elements than?: <node><node /><node /></node> If so, anyone want to venture an answer as to why this is so?
  13. If you aren't using a server-side language, then you're probably stuck using AJAX. If the file from which you want to get the data is an XML file, you can use AJAX to send a GET request to your web server to get that XML file. Once the response comes back, the XMLHttpRequest will have two ways to get at the data: .responseText and .responseXML. .responseText returns the data as plain text whereas, if the content-type of the data is "text/xml", .responseXML returns an XML document. With that XML document, you can use your favorite means of getting the data - I have been typically using the XML DOM in my projects.AJAX TutorialXML DOM Tutorial
  14. If the value in the text column will always be the value in the number column plus "G", then, rather than storing extra data in your database, why not just append the G when you return the data?Alternatively, you could simply store the letter in the text column and then append the text value in a row to the number value in a row to get the number+"G". ID, Number, Text1 1 G...547 547 G
  15. Yeah, you're right, sorry. It's targ.innerHTML. TD elements don't have a "value" property, you'll have to use innerHTML. I had a brain-wracking day yesterday!
  16. I think we'd have to see all of the code to tell you the answer to that.
  17. I thought about it on my bike ride home and came up with something else. Can you do while loops? Loops that continue until some condition is met? If so, can you also get all the elements of a certain level (like you hint at in your post)? If so, perhaps you could do something like this:Pseudo-code:level = 1;id_incrementer = 1;while(there are elements at this level){ for each (element in this level) { assign the id for the element to id_incrementer increase id_incrementer by 1 } increase the level by 1} Alternatively: level = 1id_incrementer = 1start:if(there are elements at this level){ for each(element at this level) { assign the id for the element to id_incrementer increase id_incrementer by 1 } increase the level by 1 goto start}
  18. Yeah, great looking site and I love the effects! I do have one tidbit of advice - when you click on the "Send Message" link on the Contact page without entering any information into the fields, you are presented with a rather gruff message: "Error - You must give your name!". I'm pretty sure some client looking towards you for business would rather see a more pleasant "Woops! Please provide your name before you send a message." Typically, I think it may be better to use "please" and "do" rather than "must" and "don't", especially when it comes to business.
  19. Yikes. hehWhat about something like this? Write a function that gets all the top level child elements of an element and places them in an array. This could be done with .nextSibling in javascript (the function presented on this page helped tremendously in a recent project I did). Then, in the same function, loop through that array and call that function again (recursively) on each node that is in your array. You could then have a global counter that increments by one each time an element is found and you could use that counter as your identifier for the elements. If you make sure that each element in the array is processed before the recursion happens, (e.g. maybe use two loops - once to loop through the siblings and assign an id and once again to call the function recursively) the ids should be assigned correctly. This way, the top level elements would have ids 1, 2, and 3. The children of 1 would have ids 4, and 5. The first decendents of 2 would have ids 6, 7, and 8. etc. etc.I hope it helps!
  20. If your frame has an id of "Content" then rather than doing: document.location='Standard.html'; You can use something like: document.getElementById('Content').src='Standard.html'; Then you won't have to worry about setting a target (which, I believe, only works with "a" elements).
  21. I see two issues with the code you have currently. The first issue is that the child window has an event handler set up on the mousedown event of the body element but that event handler isn't available to the child window being as the function is defined on the parent window.Rather than: <body onmousedown = whichelement(event)> You might try: <body onmousedown="window.opener.whichelement(event);"> The second issue is that the only time your text field's value changes is when you click the button on the parent window to execute your createNewDoc function. There needs to be some code that ties clicking on the td in your child window to updating the value of that text input. Since you already have an event handler that deals with clicking the mouse button on the child window, we can tie in that functionality there. function whichelement(e){ var targ; if(!e) var e = window.event; if (e.target ) targ = e.target; else if (e. srcElement ) targ = e.srcElement; // now that "targ" has a reference to the element that sent the event, // let's look at that element to see what type it is if(targ.tagName == "td" || targ.tagName == "TD") { // OK, the element that sent the event was a td element. // now we can update the content of the text input. document.getElementById("field").value = targ.value; }}
  22. You could download Firefox. :)IE has a security setting, which I do not know if it is possible to disable, that will always pop up that message when you view a file directly from your file system (e.g. c:\website\index.html) rather than from a web server (e.g. http://localhost/index.html). If you don't want to see that message anymore, either download Firefox and use it as your main browser or set up a web server using either Apache or IIS.
  23. You might check this page to see about getting the selected text:http://www.quirksmode.org/js/selected.htmlOnce you have the selected text in a variable, you can replace it like so: var selectedText; // this is what holds the selected text.// content would be the entire contents of the text, including the selected text.var newcontent = content.replace(selectedText, "[b]" + selectedText + "[/b]");
  24. Rather than this: document.GetElementById("text"+t).style.Top = -50; Try this: document.getElementById("text"+t).style.top = -50 + "px";
  25. jesh

    XML To Dataset

    Hmm, I've only had to work with XML files in .NET once, so this may not be the best solution. This is how I did it:First, make sure these are referenced: using System.Data;using System.IO; Here's the code I used. You might have to tweak it but I hope it gets you headed in the right direction. DataSet ds = new DataSet();// First, get the XML data as a Stream. You could get the stream using the File class, // I'm sure, but my data was in memory already, so I used this:byte[] xml = Encoding.UTF8.GetBytes(xmlData);Stream xmlstream = new MemoryStream(xml);// Next step, load the DataSetds.ReadXml(xmlstream);// Your DataSet now has a series of DataTables, one for each element type.// ds.Tables["Table"]// ds.Tables["Level"]// ds.Tables["Link"]// To get the DataRow in the "Level" DataTable that has an ID of 3, // you might try something like this:DataView view = new DataView(ds.Tables["Level"], "id = 3", "", DataViewRowState.CurrentRows);
×
×
  • Create New...