Consider a hiddenfield in the page HfId
<input type="hidden" id="HfId"/>
How to assign,clear and get value of a hidden field in jquery? ANy suggestion...
Whenever I load ONLY the 1.3 or 1.4 library on an html page im developing on my desktop I get an error that says "setting a property that only has a getter"
I dont have any additonal code, this is coming straight from the jquery.min.js file
I also get a bazillion warnings in Firebug.
Can someone help me resolve this issue?
I can't determine why this is happening
This is my first time building a tool like this, so please bare with me. I'm doing this to learn more about jQuery and AJAX.
Basically, I have a search input and a hidden div. When you start typing in the search input, the hidden div becomes visible and results are brought in. In this case, I'm searching for client names.
It all works fine, however I think my code could be better but I'm not sure exactly where to begin. Each keyup requests a PHP script which accesses a table in a database to find a like string. But in my PHP script, I'm echo'ing some JS/jQuery which I'm not sure is good practice. Below is my code. Am I going about this the right way or am I totally off base? Any suggestions for improvement?
Javascript
$("#search").keyup(function() {
$("#search_results").show("fast");
$.ajax
({
type: "POST",
url: "http://localhost:8888/index.php/welcome/search/" + $("#search").val(),
success: function(html)
{
$("#search_results").html(html);
}
});
});
PHP
function search($search_string = false)
{
if ($search_string)
{
$this->db->like('name', $search_string);
$query = $this->db->get('clients');
if ($query->num_rows() == 0)
{
echo "No client exists.";
}
else
{
foreach ($query->result() as $row)
{
echo '<script>';
echo '
$("#client_results_'.$row->id.'").hide();
$("#'.$row->id.'").toggle(function()
{
$.ajax
({
type: "POST",
url: "http://localhost:8888/index.php/welcome/search_client_ads/" + '.$row->id.',
success: function(html)
{
$("#client_results_'.$row->id.'").html(html).show("fast");
}
});
}, function()
{
$("#client_results_'.$row->id.'").hide("fast").html("");
});';
echo '</script>';
echo '<p><span id="'.$row->id.'">'.$row->name.'</span></p>';
echo '<div id="client_results_'.$row->id.'"></div>';
}
}
}
else
{
echo '';
}
}
function search_client_ads($client_id)
{
$query = $this->db->get_where('online_ads', array('client' => $client_id));
if ($query->num_rows() == 0)
{
echo "No ads exist.";
}
else
{
foreach ($query->result() as $row)
{
echo $row->id;
}
}
}
I currently have a form that I am building that needs to support two different versions. Each version might use a different subset of form fields. I have to do this to support two different clients, but I don't want to have entirely different controller actions for both.
So, I am trying to come up with a way to use a strongly typed model with validation attributes but have some of these attributes be conditional.
Some approaches I can think of is similar to steve sanderson's partial validation approach.
Where I would clear the model errors in a filter OnActionExecuting based on which version of the form was active.
The other approach I was thinking of would to break the model up into pieces using something like
class FormModel
{
public Form1 Form1Model {get; set;}
public Form2 FormModel {get; set;}
}
and then we would validate appropriately depending on
While John Resig's recommendation is, quite rightly, to declare all events within a jquery.document.ready() function, I know that you don't actually have to put everything in there. In fact, there are cases where it may be more appropriate to deliberately put methods outside of the ready event.
But what are those cases? Obviously best practice dictates that all events are declared within the ready event, so what would best practice be for declarations outside that event?
I'm unable to get this script to work as an extension in google chrome. No alert shows up. normal javascript alerts work.
// ==UserScript==
// @name voip
// @namespace 1
// @description voip
// @include *
// @require http://jquery.com/src/jquery-latest.js
// ==/UserScript==
$(document).ready(function() {
alert("Hello world!");
});
Is there a way using jQuery or Javascript to force a page to open in Firefox? For example, if the user has their default browser set to internet explorer, but they have firefox on their computer - open a new firefox window with the intended page. If so, I would need to check to see if they have firefox on their machine; otherwise, redirect to the mozilla firefox download site...
any suggestions?
I have a string in my db I want to pull into my page and convert to a json object.
[
{id: 1,title: "Long Event",
start: new Date(2009, 5, 6, 14, 0),end: new Date(2009, 5, 11)},
{id: 2,title: "Repeating Event",
start: new Date(2009, 5, 2)},
{id: 3,title: "Meeting",
start: new Date(2009, 5, 20, 9, 0)},
{id: 4,title: "Click for Facebook",
start: new Date(2009, 5, 27, 16),end: new Date(2009, 5, 29),
url: "http://facebook.com/"}
]
How can I do this using JQuery?
In our project we use plugin for jQuery - Galleriffic (http://www.twospy.com/galleriffic/), it allows you to do slideshow with photo set.
How to hide buttons prev/next in "pagination" block?
In the navigation ("pagination" block) should be only the page numbers without buttons prev/next.
I'm recieving the following error on trying to run an append query in access.
Microsoft Office Access set .... and it didnt't add... 779280 records(s) due to validation rule violations.
If I choose to run the query anyways, nothing actually happens.
To give some context, I'm simply trying to copy a populated field, consisting of values similar to "16-2009-02, 34-2010-02, et cetera" to another currently unpopulated field.
The fields themselves have no set validation rules, and both have the standard text field options.
I'm hoping to be able to simply remove those hyphens, and fix the issue. But I guess that's what I'm not sure about, are those hyphens actually a problem?
Running SP3 w/ Access 2003.
Thanks in advance!
I have to copy repeatedly data (contact info such as name, surname, telephone...) from form A (page 1 in domain x.com) to form B (page 2 in domain y.com)
I have been thinking about creating a chrome extension with the help of jquery to copy the data from form A, and inject it form B...
I have a feeling that this is not the best way to solve this problem...
What do you think is the best way to copy and paste data from pages in different domains?
In jQuery//dialog you can make a button like this:
dialog({ buttons: { "Ok": function() { $(this).dialog("close"); } } });
Can I make this button with a hyperlink to somewhere instead?
Hi,
All I have a Span in side the Form view. I wanted to Call a Jquery Fucntion when the from load how can i do this?
Thanks
Waiting for your reply
here is my code
<asp:FormView ID="FormView1" runat="server" OnItemCommand="FormView1_ItemCommand">
<ItemTemplate>
<asp:HiddenField ID="hidProductID" Value='<%#Eval("ProductID") %>' runat="server" />
<asp:HiddenField ID="hidCustomerID" Value='<%#Eval("CustomerID") %>' runat="server" />
<a href='<%=WinToSave.SettingsConstants.SiteURL%>WintoSave/AuctionProduct.aspx?id=<%#Eval("ProductID") %>'>
<%#Eval("ProductName")%>
</a>
<br />
<img src='<%#Eval("ImagePath")%>' alt="Image No available" />
<br />
<asp:Label ID="lblTime" runat="server" Text='<%#Convert.ToDateTime(Eval("ModifiedOn")).ToString("hh:mm:ss") %>'></asp:Label>
<span id='Countdown_<%#Eval("ProductID") %>' onload="GetTimeOnLoad('<%#Eval("ModifiedOn")%>','Countdown_<%#Eval("ProductID") %>');"></span>
<br />
<asp:Label ID="lblFinalPrice" runat="server" Text='<%#Convert.ToDouble(Eval("FinalPrice")).ToString("#.00")%>'></asp:Label>
<br />
<asp:Label ID="lblFullName" runat="server" Text='<%#Eval("FullName") %>'></asp:Label>
<br />
<asp:Button ID="btnAddbid" Text="Bid" CommandName="AddBid" CommandArgument='<%#Eval("ID")%>'
runat="server" />
</ItemTemplate>
</asp:FormView>
and following is my jquery code
function GetTimeOnLoad(shortly,DivID)
{
var dt = new Date(shortly);
alert(dt);
alert(shortly);
alert(DivID);
var ProductDivID = "#" +DivID;
alert(ProductDivID);
$(ProductDivID).countdown({
until: dt, onExpiry: liftOff, onTick: watchCountdown,
format: 'HMS', layout: '{hnn}{sep}{mnn}{sep}{snn}'
});
}
function liftOff(){};
function watchCountdown(){};
In above code I Used
' onload="GetTimeOnLoad('<%#Eval("ModifiedOn")%','Countdown_<%#Eval("ProductID") %');"
but is not working
Hi!!
I have a form and the "Name" input text is using jQuery autocomplete. What I needed was when I select a name in the list result of autocomplete, I fill the other input texts (date of birth, telephone etc) based upon the name selected.
Does anyone know how to make this second ajax call after a name is chosen?
thanks!!
Hi,
I would like to catch a click event with jquery and be able to tell if a key was pressed at the same time so i can fork within the callback function based on the keypress. for example:
$("button").click(function()
{
if([KEYPRESSED WHILE CLICKED])
{
do something...
} else {
do something different...
}
});
Does anyone know if this is possible at all or how it can be done if it is possible?
This is what I currently have:
// #content is visibility=hidden
sIFR.replace(mix_bold, {
selector: '#content p',
onReplacement: function(fi) {
$('#content').fadeIn("slow");
}
});
The fade in happens, but for a split second the replaced flash movie appears before being hidden. Has anyone gotten this to work? I am using jQuery 1.2.6 and sIFR 3 r436. Tested in Safari 4 and FF 3.
Thanks!
How do I simulate a scrollbar click with jQuery? So, if a user clicks on a div that says "scroll down," it'll be the exact same behavior as if he/she clicked on the down arrow of the browser's scrollbar. Using the current browser's behavior would be optimal, vs. doing something like $.browser.scrolldown(200,'fast').
Something like $.browser.triggerDownArrowOnScrollBar() would be sweet!
Hi Folks,
When you click the "Click an element on the page to inspect" arrow with FireBug, it puts a Blue Border around the target element, and also returns the DOM Id.
I am building an application and that feature would be awesome to add. Be able to hover over elements and highlight the target, upon clicking return the DOM Id or CSS selector to the application.
Is there a jquery plugin that does this magic? Some other smart way?
Thanks!,
Jonathan
I'm trying to load one page into another using the .load() method. This loaded page contains a script that I want to execute when it has finished loading. I've put together a barebones example to demonstrate:
Index.html:
<html>
<head>
<title>Jquery Test</title>
<script type="text/javascript" src="script/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$('#nav a').click(function()
{
$('#contentHolder').load('content.html #toLoad', '', function() {});
return false;
});
});
</script>
</head>
<body>
<div id="nav">
<a href="content.html">Click me!</a>
</div>
<hr />
<div id="contentHolder">
Content loaded will go here
</div>
</body>
</html>
Content.html:
<div id="toLoad">
This content is from content.html
<div id="contentDiv">
This should fade away.
</div>
<script type="text/javascript">
$('#contentDiv').fadeOut('slow', function() {} );
</script>
</div>
When the link is clicked, the content should load and the second paragraph should fade away. However it doesn't execute. If I stick a simple alert("") in the script of content.html it doesn't execute either.
However, if I do away with the #toLoad selector in the .load() call, it works fine. I am not sure why this is, as the block is clearly in the scope of the #toLoad div. I don't want to avoid using the selector, as in reality the content.html will be a full HTML page, and I'll only want a select part out of it.
Any ideas? If the script from content.html was in the .load() callback, it works fine, however I obviously don't want that logic contained within index.html.
I could possibly have the callback use .getScript() to load "content.html.js" afterwards and have the logic in there, that seems to work? I'd prefer to keep the script in content.html, if possible, so that it executes fine when loaded normally too. In fact, I might do this anyway, but I would like to know why the above doesn't work.
If I have many input controls in a form (There are separate validators for each of these input controls - like required,length and so on ) , there is a command button which submits the form and calls an action method. The requirement is - though the input control values are , say , individually okay - the combination of these values should be okay to process them together after the form submission - Where do i place the code to validate them together?
1) Can i add a custom validator for the command button and validate the combination together? like validate(FacesContext arg0, UIComponent arg1, Object value) but even then I will not have values of the other input controls except for the command button's/component's value right ?
2) can i do the validation of the combination in the action method and add validation messages using FacesMessage ?
or do you suggest any other approach?
Thanks for your time.
I have a rather simple form in JSP that looks like this:
<form action="response.jsp" method="POST">
<label>First Name:</label><input type="text" name="firstName" /><br>
<label>Last Name:</label><input type="text" name="lastName" /><br>
<label>Email:</label><input type="text" name="email" /><br>
<label>Re-enter Email:</label><input type="text" name="emailRe" /><br>
<label>Address:</label><input type="text" name="address" /><br>
<label>Address 2:</label><input type="text" name="address2" /><br>
<label>City:</label><input type="text" name="city" /><br>
<label>Country:</label>
<select name="country">
<option value="0">--Country--</option>
<option value="1">United States</option>
<option value="2">Canada</option>
<option value="3">Mexico</option>
</select><br>
<label>Phone:</label><input type="text" name="phone" /><br>
<label>Alt Phone:</label><input type="text" name="phoneAlt" /><br>
<input type="submit" value="submit" />
</form>
But when I try and access the value of the select box in my Java class I get null. Ive tried reading it in as a String and an Array of strings neither though seems to be grabbing the right value.
The response.jsp looks like this:
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%!
%>
<jsp:useBean id="formHandler" class="validation.RegHandler" scope="request">
<jsp:setProperty name="formHandler" property="*" />
</jsp:useBean>
<%
if (formHandler.validate()) {
%>
<jsp:forward page="success.jsp"/>
<%
}
else
{
%>
<jsp:forward page="retryReg.jsp"/>
<% }
%>
I already have Java script validation in place but I wanted to make sure I covered validation and checking for non-JS users.
The RegHandler just uses the name field to refer to the value in the form.
Any Idea how I could access the select box's value?
Hi Im using jQuery fade in/out on divs which contain images and text. It works fine in Firefox, Chrome and Safari however the effect doesn't appear to work at all in any Internet Explorer. The image disappears on fadeout the number of milliseconds I specified, but it doesn't fade.
Are there any special rules for using this in Explorer?
I'm making a slideshow and the images won't be static, they'll be pulled in dynamically through an array and finally it will look like this:
What i'm wondering is, what is more CPU friendly, CSS3 & jQuery making transitions fade simply by changing the CSS class of the div that will fill the screen, or, Canvas with drawn on it refreshing each time?
If I load an html fragment that contains images with jquery's .load(), the images aren't yet loaded when my callback is called. Since I need to do some calculations based on the dimensions of the images, I need to know when they've actually been loaded. Is there a nice way to do this?
Hey,
In a MonoRail app I have an add/edit view. On add if I don't pick a value for a dropdown I get a validation error and am forced to pick a value. However, if I then edit that same item and reset the dropdown back to the first item ("Select an Item", "0"), it saves and doesn't say it was invalid. Debugging the entity sent back to the server, I can see that it's sending the original value for the dropdown instead of the new value of "0".
What's going on here? The first thing I would expect is that it would trigger the validation since the dropdown value isn't set. The second thing I would expect is that it would send the new value I send, not the original. It does send the new value if I change it to another value, but it's as if it has internal logic that says - "I'm updating this entity and a new value was not passed, just don't change the entity value."
Thanks,
Justin