All right I have a javascript that parses my .xml files and writes the contents to individual elements in my page via the innerHTML method. That is okay for one page but what if I want to have all my pages in one xml file? Ex. I have a page called home.xml that has all the content for the home page. Another xml file for an About us page in about_us.xml and etc. What if I didn't want to have them in seperate files but in one xml file called site.xml? How would I tell my javascript which to node(?) to use. I tried things like changing firstChild to secondChild and so forth. I thought that if i was to change that index value from 0 to 1 that, that would do it for me but it didn't. I gave each page an id attribute but didn't know how to access it. Code:
First I'm sure the answer to ths JS question is buried somewhere in the many item of this forum. Just could not find it. So I'm working on changes to a form developed by someone else. In the form the previous developer wrote the following:
So my problem is this. I'm trying to access the method checkbox array from a JS function. So I write:
function setPayrollStatus() { alert(document.profile.method.length); }
This does give me that value of 4. Since there are 4 checkboxes for method I'm thinking this is correct. So next I add:
for (var idx=0; idx < document.profile.method.length; idx++) { alert(document.profile.method[idx].checked); }
Now I get only 'undefined'.
What I want to accomplish is to check the first item. I thought I would be able to write something like: document.profile. method[0].checked = true;
If I change the form name tags from 'method[]' to 'method' it works. Problem is he also wrote the php back end processing for this form. And in PHP this syntax yeilds an array for the method vriable.
I am currently attempting to write a function that retrieves the name attribute from a list of items with a specific class name. To illustrate: Code: Show types of food: <input type="radio" name="food" id="fruit" onclick="setVisibility('fruit')"/> <label for="fruit">Fruit</label> <input type="radio" name="food" id="vegetable" onclick="setVisibility('vegetable')"/> <label for="vegetable">Vegetables</label>
I would like create a function called setVisibility to iterate through all the list items where class=food and return the value of the name, so that I can compare that to the radio box, and set visibility accordingly.
I have an instance of a div (button), inside this div is a link wrapped in a span. When you hover over the div (".home-button")I want to move the background position inside its "span a", I've achieved this using the code below.
I am trying to do is load new content into a form without resetting the form. I have about 10 checkboxes, once 4 are selected I would like to reload a div in the page to insert four corresponding textareas with the same id as the checkboxes. So for example the checkboxes:
There would be about 10 after 4 are selected than four divs with textareas are loaded onto the page - These textareas have the same id in order for the right ones to load. If your wondering why not just hide the textareas and show when then have been selected by the checkboxes, its because they have a wysiwyg editor attach so it would start to load slow after I add say 10-20 different textareas.
Would this work: Code: $(document).ready(function() { $('#reload_1').click(function() { //var names = []; var myScripts = new Array(4) $('#page_select input:checked').each(function() { names.push(this).attr("id"); }); $('#content_div').load('external_content.php.html # . + '. myScripts[0]); $('#content_div').load('external_content.php.html # . + '. myScripts[1]); $('#content_div').load('external_content.php.html # . + '. myScripts[2]); $('#content_div').load('external_content.php.html # . + '. myScripts[3]); If I had all the divs and textareas in external_page.php and load only the ones needed.
Let's say I have this paragraph..<p>My dog is brown.</p I would like to accomplish this.. <p>My <span class="animal">dog</span> is brown.</p> So, I want to use JavaScript to find all "dog" strings inside the paragraph and wrap them in a SPAN element of a given class. I would love to have a plug-in that does that... like this: $("p").findAndWrap("dog", "<span class='animal' />"); I know this can be done in JS, but I'm not particularlyexperiencedin JS string manipulation, so it would take a while until I would accomplish this...Is there a plug-in that does this?
What is happening is $(this) is no longer based on .expand being the (this) that is clicked.
like if i have a button SOMEWHERE randomly on the page with this
<div onclick="Minimize('_alerts');">Click Here</div> this will minimize alerts but because the (this) in minimize function doesn't actually point to the right button that I want to add a class to.
Is there a way to modify the minimize function so that it finds the <div id="mytoggle"><ul> <li class="expand boxminimize" rel="_alerts"> using the rel toggle, and then changes the class of the li from expand boxminimize to boxexpanded??
just like the .expand click function I posted on the top of the post that works?
Another thing that has been driving me crazy is that css positioning is handled differently by different browsers. JS is not my area, but I can do a lot with CSS, and I do, but cross browser compatibility is killing me.
I can use an IF IE statement and only IE runs that segment of code, but I haven't been able to figure out out how to make ONLY firefox or ONLY opera or safari enact an encapsulated segment of code. The same type of IF statement doesn't work for them.
Is there a single method using JS that works for all browsers?
function result(){ var result = document.getElementById('resss').innerHTML; }
But what I actually want is to import data from a table of an external website. E.g. I want to get the innerHTML of a specific cell in column 3 and row 2 of a specific site.
I have a page I am working and I am having some trouble with: I need to show and hide areas based on a radio selection. I initally started using the show / hide feature in Jquery but the problem is the elements need to be removed but then put back if the user selects the radio buttonagain as it has form elements that have validaion on them. The validation is still trying to validate the form elements becuase they are still on the page but just not showing. This is the radio group the user makes the selection from:
I have HTML tags stored in XML. I want to be able to use these HTML elements with Javascript, just as you can with elements in document.body. How can it be done? (And don't try and tell me I should use server-side because I have written it all for Javascript and the project is nearly complete minus this and there are practical reasons for not doing this server-side. After all, anything is possible with Javascript!)
Let me explain:
- I have HTML templates such as this [URL]
- I want javascript to populate these templates then add them to my page
- The only way I know javascript can get this kind of data is by parsing XML
- I want to parse the XML then be able to use the HTML elements just like those in document.body
- As far as I'm aware, XML is the only good way of storing data for javascript. I don't want to store it in javascript variables (too much multiline data with " and '). Nor do I want to build it using document.createElement("div")... etc
As someone not yet with any experience in computer science etc, please ignore my poor terminology! However, I'm not a beginner when it comes to javascript.
Here's the script concerned but I doubt it'll help you understand my problem: [URL]
So i've got a form that adds an element onto the page. This is working. When I try to remove said elements, that works. But the same 'delete' button doesn't work on elements not generated by javascript.
Code JavaScript: function destroyQuickTask() { $.post($(this).attr("href"), null, null, "script");
I've got a list of DIVs on a page, each one with it's own unique id, i.e.
Code HTML4Strict:
<div id="event1"> ... </div> <div id="event2">
[code]...
This is OK, but what I really want is the ability to take the parameter specified in the URL (the #event2), and use it to somehow highlight that specific DIV.I figure the easiest way of doing this is to modify the DIV and add a class to it, such as class="highlight", then use CSS to set a different background colour - but I know very little about JavaScript,
I am developing an advent competition for my website and would like to know if there is any way of setting a specific click number to go to the desired link.
My basic idea is to have a web page with a basic advent calendar, users can click on the number for the specific day and it opens a new window with a message. If possible I would like to set a prize for one specific click, so the code can pick up on the specific number of clicks for that day from individual IP's. Eg. Day 1 I will set the click number to be 1 and the first person to click will go the winning URL link, Day 2 I will set it to be the 2nd click, etc.
I use var date1 = new Date(); to get todays date. But how can I get yesterdays date?
Furthermore I use var ydat = date1.getYear(); var mdat = date1.getMonth()+1; var hdat = "0"+date1.getDate(); var ddat = hdat.substr(htag.length-2); var datum=ydat+"-0"+mdat+"-"+ddat; to get a string like 2004-06-01 Is there a easier way to format the date?
I have a text box where the user enters their employee email address. What I want to occur is when the @ sign is pressed it will automatically add the rest (ie. mycompany.com)
I know the code required to alter the value of a text box but I dont know the event trigger or code to detect the keypress.
so that the script fills in the page. I've hacked together something that inserts the foo.shtml into foo's div then does a fooDiv.getElementsByTagName('script') and uses eval() on them and it works most of the time in some brossers but it seems hackish and somewhat dangerous and it doesn't work everywhere. Surely there's an AJAX idiom (or even a DOM built-in) to execute scripts as parts of pages load.
I am wondering if it is possible to get the response from a method within a given page, and that function alone? Traditionally, I have been getting the response from the Page_Load method of the targeted page, but now I want the response from a particular method on the target page:
Public Sub SomeCallback(ByVal sender As Object, ByVal e As EventArgs)
I am having difficulty getting the value of a specific value contained in a <p> tag, what is happening is that it retrieves the value of the first <p> tag value and not the one the user clicksWhat I need is to retrieve the value from the <p> tag the user clicked
$(document).ready(function() { $("p").click(function () { var prop = $("#property_links").val();