Jump to content

jesh

Members
  • Posts

    2,293
  • Joined

  • Last visited

Posts posted by jesh

  1. If you are trying to change the source document of the iframe, you can get a reference to the iframe using getElementById() and then setting the src property on that reference. Here's an example:

    <iframe id="myIframe"></iframe>

    var iframe = document.getElementById("myIframe");iframe.src = "http://www.w3schools.com/";

    If you are trying to bust out of the frame, and what you tried didn't work, then you might try this (inside of the iframe document):

    parent.location.href = "http://www.w3schools.com/";

  2. If you built your navigation to use nested lists instead:

    <ul>  <li>Category 1	<ul>		<li>Link 1</li>		<li>Link 2</li>	</ul>  </li>  <li>Category 2	<ul>	  <li>Link 1		<ul>		  <li>SubLink 1</li>		  <li>SubLink 2</li>		</ul>	  </li>	  <li>Link 2</li>	</ul>  </li></ul>

    Then you can take care of all that styling in the CSS:

    /* Main Level */ul { background-color: red; }/* Second Level */ul ul { background-color: green; }/* Third Level */ul ul ul { background-color: purple; }

  3. If you want to change the content on a portion of a page without reloading the entire page, you can set the innerHTML property of a div element.Here's an example that changes the innerHTML of a div when you click on a button. If you get the new content from an AJAX request, you can use the responseText property of that AJAX request as the text to display in that div:

    <html><head><script>function update(){	// first, get a reference to that div element	var div = document.getElementById("UpdateDiv");	// next, set the innerHTML property of that div to display	// the new content.	div.innerHTML = "This is some new content.";	// If you had an AJAX request called xmlHTTP, you could set	// the innerHTML like this:	// div.innerHTML = xmlHTTP.responseText;	// Just hiding the button...no particular reason.	document.getElementById("ChangeButton").style.display = "none";}</script></head><body><div>This is some static content.</div><div id="UpdateDiv">This content will change</div><button id="ChangeButton" onclick="update();">Update</button></body></html>

  4. Hi, i not sure whether this in tutorial or not but i couldn't find it. I want to know how to open new wndow after i click on the link. If i use response.redirect("xxx.aspx") it will open the page in parent. In VBscript pls. thks
    You have to use God's (sorry, Yahweh's :)) method or a javascript solution to open a new browser window. Rather than Response.Redirect("xxx.aspx"), you might look into RegisterClientScriptBlock. Here's a link for a situation that may be similar to yours:http://www.netomatix.com/RegClientScript.aspx

    CMS

    The nice part about the code above is that it displays a data tree in a SINGLE query (and its very fast), whereas using nested repeaters require dozens and dozens of queries.
    Nah, I only use a single query against the database when I use nested repeaters. I then load the data into a DataTable object and use the DataView to get at the data. Sure, filters are being applied to the DataView in code behind, but there's still only one query against the database.
    First, there's no earthly reason why you have to do anything in your code behind.
    True, you don't have to put anything in the code behind. But I find that the pages are a thousand times more easy to manage if you separate the markup from the code by placing all the code in a code behind.
  5. NF2K has it right. I don't use "with" very often, but I can see the benefit of using it from time to time.Just to provide another example, rather than:

    var div = document.getElementById("myDiv");div.style.backgroundColor = "#ff8c00";div.style.color = "#000000";div.style.width = "400px";div.style.height = "400px";div.style.borderColor = "#000000";div.style.borderWidth = "2px";div.style.borderStyle = "solid";

    You can use "with" to make it like this:

    var div = document.getElementById("myDiv");with(div.style){	backgroundColor = "#ff8c00";	color = "#000000";	width = "400px";	height = "400px";	borderColor = "#000000";	borderWidth = "2px";	borderStyle = "solid";}

  6. As for that validation script, could you be more specific? heh. I don't really know a whole lot about writing javascript.
    Oh, I was just suggesting that you put in an alert into your ValidateRequiredFields function. That way, if the page calls that function, the alert will pop up and you'll know that you're on the right track. If the alert doesn't come up, then that function isn't being called. It's just a way to start debugging your scripts.
  7. I've seen a number of people mention this time and time again:To center a block level element on the page you use margins on that element:

    margin: 0px auto;

    To center inline content (whether that be text or spans or divs styled with display="inline", etc.) you use text-align on the containing element:

    text-align: center;

    If you have a DIV that you want centered in the body and you want the text (or other inline content: like an image) inside that DIV to be centered, you'd do it like this:

    <style type="text/css">div.centered{	margin: 0px auto;	text-align: center;}</style><div class="centered" style="width: 75%; border: 1px solid green;">  The width of block-level elements default to 100% of the containing element's width  so if you want to center this div inside the body, you have to specify the width as something  other than 75%.  The border is there so you can see the div.</div><div class="centered" style="width: 50%; border: 1px solid red;">  <img src="http://w3schools.invisionzone.com/style_images/w3sbanner.gif" /></div>

    EDIT: of course, this code only works in compliant browsers (i.e. not IE6). Man, I hate IE.

  8. well..tq 4 all the info..but suddenly i was thinking that I if could set my server to make all user must have to view my default page first before they could go anywhere...any possibilities?
    Are you talking about when a visitor first comes to your website you want to insure that s/he is directed to your default page before they can view any other page in your site?I would think that you could accomplish this with cookies and a javascript that was loaded on each page.Idea: Build a javascript that would be included on each and every page of your site. This javascript would look for a cookie in the visitor's browser to see if s/he has been to the site yet this session. If so, let them continue his/her browsing. If not, redirect the visitor to the default page using the location.href method mentioned by pulpfiction. Then, once the user loads the default page, set a cookie in their browser that expires at the end of the session indicating that the visitor had visited the default page and was free to navigate around the rest of the site. Once the browser session ended, the process would begin from the start and the visitor would be forced to see the default page.If this is not what you're talking about then you need to listen to aspnetguy and realize that what you are asking is impossible (and rightly so).
  9. After some random testing.. I discovered that this script has only stopped working on Firefox. It still works on IE and on Opera. Very confusing.
    Does Firefox report any errors? If so, what are those errors? If not, you might try adding an alert in the validation code just to make sure that the code is executing:
    function ValidateRequiredFields(){alert("Well?  Does this show up?");var FieldList = RequiredFields.split(",")...

    I noticed that on your Contact Us form, you're using a file called mail.js whereas on the Apply form, you're using app.js. Perhaps there's a minor difference between the two codes that you may be overlooking?

  10. Ok, Thank you! Are you sure their database and the database I have in mind are the same?
    The database table(s) that is set up in that tutorial is most likely not set up the same way you need to set up your database table(s), but the idea is that you can learn how to use SQL to create what you need. You'll probably have to take what you learn in that, and other tutorials, and figure out how to adapt it to fit your own project.
  11. That sounds great but can I use it even though I'm using a web host? Also is there anything else after that? I'm willing to go through some tutorials.
    Depending on whatever package you get from your web host, they may have a database system set up for you to use. If you are using PHP, the host typically bundles that with MySQL. If you are using ASP(.NET), the host may bundle that with SQL Server.Once the database system is all set up, you can find a number of tutorials on the Internet about SQL. There's one here at W3Schools: http://www.w3schools.com/sql/default.aspIf you run into any problems, you might head over to the SQL forum here and the people there should be able to help.

    CMS

    I might have to try out both methods, but method might work for my case as there is not fixed number of links, also the links are grouped into categories. and the number of groups are variable. so if im using a asp:repeater, then I need to create repeater on the fly. and may positioning it might get difficult..... Right???
    Heh, yeah, nested Repeaters can get a little hairy. The basics of it go like this:ASPX
    <asp:Repeater id="GroupRepeater" OnItemDataBound="GroupRepeater_ItemDataBound" runat="server"><HeaderTemplate></HeaderTemplate><ItemTemplate>  <%# DataBinder.Eval(Container.DataItem, "GroupName") %>  <ul>  <asp:Repeater id="LinkRepeater" runat="server">  <HeaderTemplate></HeaderTemplate>  <ItemTemplate>    <li>      <a href="<%# DataBinder.Eval(Container.DataItem, "URL") %>">        <%# DataBinder.Eval(Container.DataItem, "LinkText") %>      </a>    </li>  </ItemTemplate>  <FooterTemplate></FooterTemplate>  </asp:Repeater>  </ul></ItemTemplate><FooterTemplate></FooterTemplate></asp:Repeater>

    ASPX.CS

    // First, you'll have to bind the data to the GroupRepeater.// This is the ItemDataBound event handler.  This fires each time an item is bound to the repeater.protected void GroupRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e){    RepeaterItem item = e.Item;    switch (item.ItemType)    {        case ListItemType.Item:        case ListItemType.AlternatingItem:            foreach (Control control in item.Controls)            {                if (control.GetType() == typeof(Repeater))                {                     Repeater repeater = (Repeater)control;                     // Get the current group ID from the RepeaterItem.                     int groupID;                     int.TryParse(DataBinder.Eval(item.DataItem, "GroupID").ToString(), out groupID);                     // Next, get all the links for that particular group and put them into some collection                     // Maybe a DataTable?  Don't know how you have this set up.                                          // Finally, set the DataSource for the Repeater with that collection:                     repeater.DataSource = data;                     repeater.DataBind();                     break;                }            }             break;    }}

    CMS

    I typically stick with the Repeater control:

    <asp:Repeater id="LinkRepeater" runat="server"><HeaderTemplate>  <ul></HeaderTemplate><ItemTemplate>  <li>	<a href="<%# DataBinder.Eval(Container.DataItem, "URL") %>">	  <%# DataBinder.Eval(Container.DataItem, "LinkText") %>	</a>  </li></ItemTemplate><FooterTemplate>  </ul></FooterTemplate></asp:Repeater>

    Then just bind the data to that repeater just like you'd bind a DataGrid or DataList.

  12. pulpfiction's code gets the selected value from a drop down menu. An alternative way to do it would be like this:If this were your HTML:

    <select id="LISTBOX1"><option value="option1">Option 1</option><option value="option2">Option 2</option><option value="option3">Option 3</option></select>

    You can get the selected value in your javascript like this:

    var select = document.getElementById("LISTBOX1");var value = select.options[select.selectedIndex].value;

  13. Without looking too deeply at what this script does, I would suggest that you try adding the following function to your java script:

    function doItAgain(){	curobjindex=0;	collectElementbyClass();}

    And then calling that new function in a button's onclick event in the HTML:

    <button onclick="doItAgain();">Start it Again!</button>

  14. Let's say you had your system set up where the page was looking for a query string variable called "video" and depending on what value was stored in "video" it would determine which video was loaded on your page.You could, perhaps, store the URL to your videos in an array:

    var videos = new Array();videos[0] = "somevideo.mpeg";videos[1] = "anothervideo.mpeg";videos[2] = "athirdvideo.mpeg";

    And you could link to your video using something like this:

    <a href="?video=0">View Some Video</a><a href="?video=1">View Another Video</a><a href="?video=2">View a Third Video</a>

    Then, using that code you posted, you could get at the variable passed in the link like so:

    var videoIndex = getQueryVariable("video");

    And, then, you can get the URL to the video out of your array like this so that you can use it to switch the videos on the page:

    var videoURL = videos[videoIndex];

  15. In ASP.NET (C#) I would do something like this to get a C# variable into my java script:

    <script type="text/javascript">var userid = <%= UserID %>;</script>

    I'm guessing, in PHP, it'd be something like this:

    <script type="text/javascript">var userid = <?php echo $UserID; ?>;</script>

  16. I think that as long as you put an index on whichever field(s) you are using in your WHERE clause, even with millions of records, the results will come back relatively quickly.You may also consider storing all of the records in one table and a sort of "rollup" in another table which only has the messages that were received in the last day (or week or whatever). Then, to pull the most recent messages, you'd only have to pull from thousands of records and you'd only need to pull from the millions of records when you want to display an archived message.

×
×
  • Create New...