This one is throwing me off! Either I am making a stupid mistake or I'm doing it totally wrong I have an array, and I am trying to select unique values from it and assign it to another array. Here is the code:
Code: var flag; for (i=0;i<=pdfs.length-1;i++) { flag = 1; for (j=0;j<=pdfs2.length-1;j++)
[Code]...
The problem is that the if (pdfs2[j] == pdfs[i]) statement ends up never being true. There are URL's to pdf files in the array. On the other side, if there is a much easier way to select unique values from an array, please feel free to point it out.
Years ago I created HTML that employs checkboxes and textboxes. I am now writing JS with the intention of adding flexibility and limiting redundancy. I am not sure I truly understand how to correctly interact the two though. For example, one of my scripts have arrays that contain the names of the checkboxes and textboxes, with a 'for' loop to document.write() them to references within the HTML code.This does not seem to be working for me though. Here is what I have thus far (in short):
<script language="javascript"> var teamNames = new Array(3); teamNames[0]="South Africa"; teamNames[1]="Mexico"; teamNames[2]="Uruguay";
[Code]...
I've left out a lot of the code (to include the teamAbbr array, but you get the points. I've tried moving the JS within the HTML body and playing with the reference syntax, but nothing so far.
For some reason my script only works when I have at lease two checkboxes. To simulate the problem just run it once with two html input checkbox elements
-> check one checkbox and press submit -> it works -> Now remove one input checkbox field and check the remaining checkbox & submit -> Bamm doesn't work...
I have a problem with html select. i will be selecting an element from the select drop down, then i will click a button which will result in changing the position of this element with the element just above it. Is it possible, I am getting the element id, I thought of using replaceWith method, but its giving some error. "uncaught exception: Syntax error, unrecognized expression: # ". I also wanted to know if this thing is possible in jquery or not..
I have a form that is pretty large, so to break it up I hide certain fields unless the information is required.
The problem is this. Lets say that I select that I a have a dog, put in some information in the newly shown fields, and then decide I don't want to say that I have a dog. If I select no to the dog question (the radio button that shows or hides the fields) the information I entered is still there. I need the information in those fields to be cleared when the fields are hidden.
this is the structure of my current HTMl [code]...
If the person says the have a dog, then all fields with class .dog_hidden will be shown, otherwise they are hidden. How can I select all form field types contained within a div of class="dog_hidden" and clear there value (either reset or set to an empty string " ") .
The goal is that every time the fields are hidden they need to be cleared or zeroed. Its important that this information never get put into the database (all fields with a value will be entered).
Do you know why js does not reset this multi select box? <select name="LOB" multiple="multiple" size="5" style="background:#fff3b3;width:150px" > <option value="DP" >DP</option> <option value="DTV" >DTV</option> <option value="HSD" >HSD</option> <option value="PPV" >PPV</option> <option value="RF" >RF</option> <option value="VOD" >VOD</option> </select>
Code: function clearForm(oForm) { var elements = oForm.elements; oForm.reset(); for(i=0; i<elements.length; i++) { field_type = elements[i].type.toLowerCase(); switch(field_type) { case "text": case "password": case "textarea": case "hidden":
elements[i].value = ""; break; case "radio": case "checkbox": if (elements[i].checked) { elements[i].checked = false; } break;
case "select-one": case "select-multi": //alert(elements[i].value); elements[i].selectedIndex = -1; break; default: break; }}}
how to add extra properties to html elements as I was storing data in html attributes. After looking at some others code including Raphael and this addEvent code. [URL] They seem to treat objects just like an array. obj[property] = value; This would have been extremely helpful to know previously as I have needed to be able to include variables in property names - but have resorted to making the whole thing a string and calling exec() on it.
So before I used jQuery I had this approach to set select field as not selected. So the question is what would be the equivalent way to do it in jQuery? Code JavaScript: if (tag == 'select'){ this.selectedIndex = -1; }
I have a multiple select list that is created dynamically based on a previous selection on an asp page. The first thing I do is to clear the curent option list by
document.form1.itemcross.length = 0;
The only problem is that it leaves the optgroups. How do I also get rid of the optgroups?
I have a select dropdown with several options. The user selects an option and fills out the following few fields. If the user then changes his mind and changes the option in the dropdown, I want all the fields - or just the ones already filled out - to be cleared.
Note: reset() of the form is not an option as there are other things going on (hide/display of fields based on the dropdown option selected).
I have an ajax dependent drop down set up for location fields and am having trouble figuring out how to clear the dependent selects if the parent select is changed to blank.I set up a function to clearFields:
<script> function clearFields() { document.getElementById('cb_state').value = "";
I have a large set of input fields (of checkboxes and radio buttons), and aside each set, is a clear button (just looks like text you can click on) that clears any input next to each of the input fields. When no input buttons are selected, the HTML entities that depend on them are supposed to disappear, and this works on load.
My question is how does one easily incorporate that clear button so that it tells the listeners already in action to clear those entities when they click on clear, and without having to manually do it over again with the clear button, if that makes any sense.
I have known insertBefore which insert HTML tag before another HTML tag. Now I want insert HTML tag AFTER another HTML tag. I searched, but not found. There isn't insertAfter ....
I'd like to reorganize the third, fourth, fifth and sixth, as well as any elements thereafter in an array in random order:
var a = new Array('first','second','third','fourth','fifth','s ixth','etc')
In other words, the first, second and third element should remain in position 0, 1 and 2, while the fourth, fifth and sixth, etc. should appear in random order.
I just started to learn jquery. The sitepoint book I picked up and my online research did not yield any results for what I am trying to do.
Basically I have a ul with li in it. I have the ul's width set so that only 4 LI's are displayed in one row and then the next set of 4 gets displayed in next row, etc.
Can I use jquery to simply say 'after each set of 4 li, insert a graphic' .. or insert some html code.
I want a graphical separator between sets of <li>'s
I have this site that uses AJAX, I have a basic understanding of AJAX and javascript.[code]This is executed with a onclick event on a div tag. The supposed reaction is for the ajax to pull echoed html code (an image and a title inside a <p> tag) from the write2.php page which has no problems and replace whatever is inside of the Div tag with that. The Div tag by the way already has an image and a title inside a <p> tag.[code]
I am trying to use the lalit.lab font detector in order to serve different style sheets based on what fonts the user has installed. My problem is that I don't know how to insert the <link rel="stylesheet" href="/stylesheets/css1.css"> into the HTML via javascript. The code I have is something like this (i know it's not actually javascript code):
Code: if (detective.test('candara')) { // tests if the font is installed <link rel="stylesheet" href="/stylesheets/css1.css"> // here it should write to the html la link to the css } else { <link rel="stylesheet" href="/stylesheets/css2.css"> }
I found something but it only works with html elements:
I develop a component that inserts radio buttons into an div, after this it use the jquery ui buttonset widget on this elements.
This works like this example:
This works like expected.
But when I submit the parent form or when I register an change event with $('#thediv > input').change(function() {alert('test');}); it does not send the values of this radio buttons.
With firefox it works fine only matters IE7 .
You can see this live in Struts2 jQuery Plugin Showcase goto "Ajax Forms > Buttonset / Radio Buttons"
The following code (HTML) generates a table. Now I'd like to insert a new row by a javascript.
The following code (javascript) works with the Internet Explorer and also with Mozilla. However, the inserted button (onClick) in the table does not work with the Internet Explorer. It only works with Mozilla. Code:
I'm working on a navigation menu where I want to insert some html after a UL element.
Here's the statement: selUL.eq(x+1).after('<b>hello</b></div><div class="subMenu">'); I'm trying to insert it after the following <ul> element: <div class="subMenu"> <ul
[Code]...
It's like it's trying to auto correct me. I need it to print everything exactly as I have it, otherwise my navigation won't divide into separate columns. Anyone have an idea why it's doing this? If I remove the <div> elements and just use the <b> element it works fine.
EDIT: After some more testing, the After method seems to strip out any closing elements not yet opened (</div>) and automatically closes any elements opened but not closed (<div class="subMenu">). Anyone know of a way to stop this from happening?
I stumbled upon something which may be by design in jQuery for security reasons, it may be the browsers doing it, but... I found that any JavaScript I try to put into the html of an object is ignored. For example, say username is a variable that was already defined with the user's name:
$("#test").html("Hi there <script type='text/ javascript'>document.write(username);</script>. ");
All the script is just stripped out, in both IE and Firefox.