when using JQuery, HTML, PHP is mandatory to make your web pages validate even when JQuery, HTML and PHP can sometimes cause havoc as well as being backwards compatible,
I need to trigger a click function assigned to a checkbox, but without actually changing it's checked state (which click() does).
Scenario: I have a form with several checkboxes that when selected reveal a textarea. This works fine, but I also need to call the click() function on $(document).ready()
My code is below, please note I have very limited access to changing the generated html. I have an object (admin_panels) which will store each checkbox and the texarea it should bring up.
var admin_panels = {"checkbox-id" : "textarea-id"};
$(document).ready(function(){
for (var elem in admin_panels) {
$("#" + elem).click(admin_slide);
// $("#" + elem).click();
}
})
function admin_slide() {
if ($(this).is(":checked")) {
$("#" + admin_panels[this.id] + "-wrapper").slideDown();
}else{
$("#" + admin_panels[this.id] + "-wrapper").slideUp();
}
}
Thanks
I have developed a site http://www.ssitfriends.com/ and i used jquency fancy transitions....
when i saw my sight in firefox my banner moves to right causing an annoying effect..... How to get rid of this?
Hi
Case is I want to prompt a message (Do you want to save changes?) if text box default value is updated on .aspx page before submitting the page. I am using .text() to compare with .val().
It works fine in firefox but failing in IE7 and IE8
if ($("#<%=txt1.ClientID%>").attr("value") === $("#<%=txt1.ClientID%>").text())
return(true);
return confirm('Do you wish to save these changes?');
I am stuck with a kind of bug in FF, wherein it’s unable to load images of big size (I have 8 MB size of image) from the server. The loading of image is all fine on IE. I am still looking out for ways to get rid of this problem.
I changed server(IIS) settings to allow bigger file sizes. Also, I used “load” event on image using JQuery and tried all sort of options listed here http://api.jquery.com/load-event/, but nothing worked so far. If anyone of you has come across any such similar problem, and a way to resolve it, it would be nice to hear from you
Please note: high resolution images are part of the requirement.
Code :
<style>
img {
background-color: #FFFFFF;
background-image:
url(http://eremurus.hyd:8080/QMS/plugin/imagepanner/loader.gif);
background-repeat: no-repeat;
background-position: center center;
}
</style>
<script src="../plugin/jquery-ui-1.8.7.custom/js/jquery-1.4.4.min.js"
type="text/javascript"></script>
<script>
jQuery(document).ready(function($){
///var _url = "http://eremurus.hyd:8080/QMS/plugin/imagepanner/floorPlan.jpg";
// set up the node / element
_im =$("#main");
//_im.bind("load",function(){ $(this).fadeIn(); });
// set the src attribute now, after insertion to the DOM
//_im.attr('src',_url);
$("#main").one("load",function(){
alert('loaded');
})
.each(function(){
if(this.complete){
$(this).trigger("load");
}
});
});
</script>
</head>
<body>
<div id="target"><img id='main' src="http://eremurus.hyd:8080/QMS/plugin/imagepanner/floorPlan.jpg"> </img></div>
</body>
</html>
i want to remove the id attribute from this image:
<img width="270" class="thumb" id="thumb" height="270" src="img/1_1.jpg" />
i tried doing this:
$('img#thumb').RemoveAttr('id','none');
but its not remving it!
thanks
EDIT:
$('img#thumb').attr('src', response);
$('img#thumb').attr('id', 'nonthumb');
this deosnt load the picture, or in this case the src!! but when i remove the id attribute, it works fine
This link shows you that jQuery uses (new Function("return " + data))(); for older browsers, to parse a JSON string instead of eval().
What are the benefits of this? What if the JSON string isn't safe?
I've got an html table:
<table><tr>
<td>M1</td>
<td>M2</td>
<td>M3</td>
<td>M4</td>
</tr></table>
and a simple jQ script:
$('td').click(function(){ alert( $(this).html() ); });
That works just fine.... but in the real world, I've got several hundred table cells and the code is formatted improperly in places because of several people editing the page.
So if the html is:
<td>
M1
</td>
then the alert() is giving me all the tabs and returns and spaces:
What can I do to get ONLY the text without the tabs and spaces? I've tried .html(), .val(), .text() to no avail. Thanks!
I have datepicker code is this..
$("input[id^='exc-flwup-']").datepicker({
duration: 0,
constrainInput: true,
showTime: true,
stepMinutes: 30,
stepHours: 1,
altTimeField: '',
time24h: true,
minDate: 0
});
Input field is
<label for="FollowupDate">
Follow-up:
<input type="text" id="exc-flwup-<%=Model.ExceptionID %>" name="exc-flwup-<%=Model.ExceptionID %>" value="<%=Model.FollowupDate %>" />
</label>
First click on input box I am getting popup window I can select the date.. but when I am trying to clear the date from Inputbox.. when I click on the input box again is tehre any way that we canclose the popupwindow?
thanks
My service is built and it is sending the config variable to my js file:
[['SpellChecker','-','Undo','Redo','-','Bold','Italic','Underline','NumberedList','BulletedList']]
The above is assigned to my javascript like so:
var config = "<?= stripslashes($_REQUEST['config']) ?>";
I can alert out the config just fine:
console.log(config) does send back the correct data...
However, I get an error thrown in my console!:
v is undefined [Break On This Error]
var
u=n.toolbox.toolbars,v=n.config.to...aximize','ShowBlocks','-','About']];
If I comment out the config:
//CKEDITOR.config.toolbar = config;
everything works fine but the configuration doesn't exist, of course...
I have a button that when hovered displays a div.
How can I postion this div to appear directly under the button when displayed???
<script type="text/javascript">
$(document).ready(function(){
$(".plans").hover(function() {
$("#planssubnav").show("slow");
}, function(){
$("#planssubnav").hide("slow");
});
});
</script>
<a href="/plans" style="font-size:14px;" class="plans fg-button fg-button-icon-right ui-state-default ui-corner-all"><span class="ui-icon ui-icon-circle-triangle-s"></span>Plans</a>
<div id="planssubnav" style="display:none">
<h1> content</h1>
</div>
$("input[id^='Date-<%=Model.ID%>']").datepicker({
duration: 0,
buttonImage: '/Content/images/calender.gif',
buttonImageOnly: true,
showOn:'button',
constrainInput: true,
showTime: true,
stepMinutes: 30,
stepHours: 1,
altTimeField: '',
time24h: true,
minDate: 0
});
I have this Calender Control I am using..user can select any date from the calender.. I need to validate the dates like Saturday and Sundays and 1/1 and 1/25.. if they select these days I need to show them Popup message not valid date?
can anybody help me out..
thanks
I Have a function that references a specific input text box. I would like to extend the function to be used by two specific input text boxes. Rather than duplicate the code for the other text box, can anyone advise on how to reference the other?
Here it uses #Tags, but if i wanted it to reference #Tags2 also, how could I do that?
$(function () {
$('#Tags').tagSuggest({
separator: ", ",
tagContainer: 'div',
tags: ["tag1","tag2"]
});
});
I got something that I want to do and want to see what you guys think and how can it be implemented.
I got a form in a page and the form will submit to itself to perform some process (run functions) in a class.
Upon clicking the submit button, I want to animate the button text to
“SUBMIT .” -> “SUBMIT ..” -> “SUBMIT …” -> “SUBMIT ….” -> “SUBMIT ….” and then back again.
Sort of “animate” the button text.
Once the whole process is done, the button text will goes back to be “SUBMIT” text again.
Please note that I am not looking for image button solution, meaning that I do not want to implement gif animated button image.
Anyone done this before or know how this can be done? I have google but seems nothing of this kind to be found.
Thanks!
AL
I thought it would be simple but I still can't get it to work. By clicking one button, I want several animations to happen - one after the other - but now all the animations are happening at once. Here's my code - can someone please tell me where I'm going wrong?:
$(".button").click(function(){
$("#header").animate({top: "-50"}, "slow")
$("#something").animate({height: "hide"}, "slow")
$("ul#menu").animate({top: "20", left: "0"}, "slow")
$(".trigger").animate({height: "show", top: "110", left: "0"}, "slow");
});
I have the following line of code:
<li id="1" class=" ">
<a href="">Parking Lot</a>
<span id="1" class="list-edit">edit</span>
</li>
I then have two binds:
$("#lists li").click(function(){.......
$(".list-edit").click(function(){.........
The problem I'm having is I need the LI to contain the EDIT span because of CSS styling reasons, I have a big blue background. But this is preventing me from binding the EDIT btn. Is there a way to get these two to play nice?
Thxs
I have a function. I pass to it an object with a list of questions and answers. I generate a random number from a range equal to the number of questions in the object. The script check to see if that question has been asked, and if not, it asks it, the correct answer is then passed to a variable correct. I want to give 4 possible answers, each one randomly selected from the list of possible answers. I have this. I just want to know what is the best way to ensure that the correct answer is placed in the list.
So far, this is what I have: it puts four answers into four targeted boxes. I want to ensure that the correct answer is in a randomly selected box.
function getRandom(limit) {
return Math.floor(Math.random() * limit )
}
$("#answers > .answer").each(function(i){
r = getRandom(total_questions);
$(this).text(answers[r])
});
I want to do something like this:
$('.dynamicHtmlForm').validate = function() {
return true;
}
$('.dynamicHtmlForm .saveButton').click(function() {
if (!$(this).closest('.dynamicHtmlForm').validate()) {
return false;
}
return true;
});
And then when I have a form of class dynamicHtmlForm, I want to be able to provide a custom validate() function:
$('#myDynamicHtmlForm').validate = function() {
// do some validation
if (there are errors) {
return false;
}
return true;
}
But I get this when I do this:
$(this).closest(".dynamicHtmlForm").validate is not a function
Is what I've described even possible? If so, what am I doing wrong?
I have the following function:
var emptyFields = false;
function checkNotEmpty(tblName, columns, className){
emptyFields = false;
$("."+className+"").each(function() {
if($.trim($(this).val()) === "" && $(this).is(":visible")){
emptyFields = true;
return false; // break out of the each-loop
}
});
if (emptyFields) {
alert("Please fill in current row before adding a new one.");
} else {
AddRow_OnButtonClick(tblName,columns);
}
}
Its checking that all elements in the table are not empty before adding a new row, and I only need to check that the last row of the table has at least an element which its not empty and not the whole table.
Any help would be apreciated.
Thanks
Hi,
I want to pass the result of a query trough a $.post.
function GetAllTasks()
{
$sql = "select t.id as task_id,
description,
createdat,
createdby,
max_requests,
max_duration,
j.name as job_name
from darkfuture.tasks t, darkfuture.jobs j
where t.job_id = j.id";
$sqlresult = mysql_query($sql)
or die("The list of works failed: ".mysql_error($this->con));
$result = array();
while($row = mysql_fetch_assoc($sqlresult))
{
$task = new TasksResult();
$task->id = $row["task_id"];
$task->description = $row["description"];
$task->createdat = $row["createdat"];
$task->createdby = $row["createdby"];
$task->max_requests = $row["max_requests"];
$task->max_duration = $row["max_duration"];
$task->job_id = $row["job_name"];
array_push($result, $task);
}
mysql_free_result($sqlresult);
return $result;
}
Here is how i call it:
$tasksDB = new TasksDB();
$tasks = $tasksDB->GetAllTasks();
Now i want to pass $tasks through here:
$.post("views/insert_tasks.php",{'tasks[]': $tasks}, function(data)
{
});
I know this {'tasks[]': $tasks} it's wrong but i don't know how to do it right.
Some help will be appreciated.
Thanks in advance!
info = {'phone_number': '123456', 'personal_detail': {'foo':foo, 'bar':bar}, 'is_active': 1, 'document_detail': {'baz':baz, 'saz':saz}, 'is_admin': 1, 'email': '[email protected]'}
return HttpResponse(simplejson.dumps({'success':'True', 'result':info}), mimetype='application/javascript')
if(data["success"] === "True") {
alert(data[**here I want to display personal_detail and document_details**]);
}
How can I do this?
Hi.. For example i have 5 checkbox, 3 checkbox with name=a[] and 2 checkbox with name=b[], if i checked array a[] 3checkbox iam getting the same value for b[] checkbox even b[] checkbox not checked. please suggest...
For ur reference:
var selectedAItems = new Array();
$("input[@name='a[]']:checked").each(function() {
selectedAItems.push($(this).val());
});
var selectedBItems = new Array();
$("input[@name='b[]']:checked").each(function() {
selectedBItems.push($(this).val());
});
alert(selectedAItems);
alert(selectedBItems );