jQuery Plugins » Getting https://jqueryplugins.info jQuery plugins, tutorials and resources Wed, 19 Oct 2011 13:14:08 +0000 en hourly 1 http://wordpress.org/?v=3.2.1 Getting the selected option with jquery https://jqueryplugins.info/2011/10/getting-the-selected-option-with-jquery/ https://jqueryplugins.info/2011/10/getting-the-selected-option-with-jquery/#comments Fri, 14 Oct 2011 11:15:28 +0000 Admin https://jqueryplugins.info/2011/10/getting-the-selected-option-with-jquery/ Post link: Getting the selected option with jquery

I have this; <select id='list'> <option value='1'>First</option> <option value='2'>Second </option> <option value='3'>Third </option> </select> i want to specifically get the option selected and put it an a variable, then alert...

]]>
Post link: Getting the selected option with jquery

I have this;

<select id='list'>
    <option value='1'>First</option>
    <option value='2'>Second </option>
    <option value='3'>Third </option>
</select>

i want to specifically get the option selected and put it an a variable, then alert what’s in the variable.
I tried

var value = $  ("#list option:selected").text();
alert(value);

but its not working :(
Ps: i need the selected value in a variable.
Thanks

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/getting-the-selected-option-with-jquery/feed/ 0
Empty form is getting sumitted in php/jquery https://jqueryplugins.info/2011/10/empty-form-is-getting-sumitted-in-phpjquery/ https://jqueryplugins.info/2011/10/empty-form-is-getting-sumitted-in-phpjquery/#comments Thu, 13 Oct 2011 05:18:17 +0000 Admin https://jqueryplugins.info/2011/10/empty-form-is-getting-sumitted-in-phpjquery/ Post link: Empty form is getting sumitted in php/jquery

I have written the following code using jquery and php to submit the form when user clicks on save button, the form is getting submitted successfully but the forma data...

]]>
Post link: Empty form is getting sumitted in php/jquery

I have written the following code using jquery and php to submit the form when user clicks on save button, the form is getting submitted successfully but the forma data is empty (post data)

This is what i am doing :

I am checking whether the save button is clicked, if so then i am sending a mail and setting the form action then submitting the form.

<form id= "contactform"  method='POST'>
 .......
<input type='submit' name='submit_details' value=Save />
</form>

<script type="text/javascript">

function submit_form()
{
   $  ("#contactform").attr("action","https://functions.php");
   $  ("#contactform").submit()
 }

<?php
if(isset($  _POST['submit_details']))
{

   mail("[email protected]", $  subject, $  mailbody, $  headers);
   echo "<script> submit_form(); </script>";
}

?>

but when i call the the javascript function directly, the form data will pass

<form id= "contactform" onsubmit='javascript:submit_form();' method='POST'>

So, what is the problem here.

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/empty-form-is-getting-sumitted-in-phpjquery/feed/ 0
Getting alert empty from php code ? https://jqueryplugins.info/2011/10/getting-alert-empty-from-php-code/ https://jqueryplugins.info/2011/10/getting-alert-empty-from-php-code/#comments Sun, 09 Oct 2011 20:13:24 +0000 Admin https://jqueryplugins.info/2011/10/getting-alert-empty-from-php-code/ Post link: Getting alert empty from php code ?

I not know why in following js code alert is empty without html code, my view have html code, and my_class work true for other controller, when i get alert...

]]>
Post link: Getting alert empty from php code ?

I not know why in following js code alert is empty without html code, my view have html code, and my_class work true for other controller, when i get alert this means it is work true js code but get data of php code without html. what do i do?

function guide_show($  offset = 0) {
$  find = $  this -> input -> post('find');
$  where = "name LIKE '%$  find%' OR phone LIKE '%$  find%' OR mobile LIKE '%$  find%' OR address LIKE '%$  find%' OR date_submit LIKE '%$  find%' OR useradmin_submit LIKE '%$  find%'";
$  table = "guide";
$  url_pag = "admin/submits/guide_show";
$  order = "id";
$  data = $  this -> my_class -> show($  where, $  table, $  url_pag, $  order, $  offset);
    $  this->load->view('admin/guide_show', $  data);
}

jQuery:

$  .ajax({
    type: "POST",
    dataType: "html",
    url: url,
    data: dataString,
    cache: false,
    success: function (html) {
        alert(html)
    },
    "error": function (x, y, z) {
        // callback to run if an error occurs
        alert("An error has occured:\n" + x + "\n" + y + "\n" + z);
    }
})

Here is My_class(library): http://pastebin.com/6DxjmBFC

Here is my htm code in view(guide_show): http://pastebin.com/mtubjzvB

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/getting-alert-empty-from-php-code/feed/ 0
Getting last class from a other class https://jqueryplugins.info/2011/10/getting-last-class-from-a-other-class/ https://jqueryplugins.info/2011/10/getting-last-class-from-a-other-class/#comments Fri, 07 Oct 2011 18:17:39 +0000 Admin https://jqueryplugins.info/2011/10/getting-last-class-from-a-other-class/ Post link: Getting last class from a other class

I want get last class in .fine_class, but my code give me undefined. how can fix it? Example: http://jsfiddle.net/gBxan/ <div class="find_class"> <div class="class1"></div> <div class="class2"></div> <div class="class3"></div> <!-- I wan...

]]>
Post link: Getting last class from a other class

I want get last class in .fine_class, but my code give me undefined. how can fix it?

Example: http://jsfiddle.net/gBxan/

<div class="find_class">
    <div class="class1"></div>
    <div class="class2"></div>
    <div class="class3"></div> <!-- I wan get class this div -->
</div>

var find = $  ('div.find_class div:last').find('div:last').attr('class');
alert(find);

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/getting-last-class-from-a-other-class/feed/ 0
Getting a nice transition effect with jquery, php sessions and a page refresh? https://jqueryplugins.info/2011/10/getting-a-nice-transition-effect-with-jquery-php-sessions-and-a-page-refresh/ https://jqueryplugins.info/2011/10/getting-a-nice-transition-effect-with-jquery-php-sessions-and-a-page-refresh/#comments Fri, 07 Oct 2011 01:13:59 +0000 Admin https://jqueryplugins.info/2011/10/getting-a-nice-transition-effect-with-jquery-php-sessions-and-a-page-refresh/ Post link: Getting a nice transition effect with jquery, php sessions and a page refresh?

I am looking to make a nice transition effect for a dynamic user layout system I have created. My layout relies on a session being either the value of 1...

]]>
Post link: Getting a nice transition effect with jquery, php sessions and a page refresh?

I am looking to make a nice transition effect for a dynamic user layout system I have created.

My layout relies on a session being either the value of 1 or 2, I then call the layout using a switch statement.

switch ($  _SESSION['layout']) {

    case 1: break;
    case 2: break;
}

I have also created a button that they can click to change the layout using ajax. The jquery for this is like so:

$  ('#changeLayout').click(function() {

    $  .ajax({data: {changeLayout: 'mainLayout'}});
    $  ('#fluidWrap').fadeOut();
    setTimeout(function() {
        window.location = 'http://www.example.com/preferences';
    }, 1000);
return false;
});

The ajax is as follows:

if ($  _SESSION['layout'] == 1) {

    $  q = $  dbc -> prepare("UPDATE layout SET layout = 2 WHERE id = ?");
    $  q -> execute(array($  _SESSION['id']));
    $  _SESSION['layout'] = '2';
}
else {
    $  q = $  dbc -> prepare("UPDATE layout SET layout = 1 WHERE id = ?");
    $  q -> execute(array($  _SESSION['id']));
    $  _SESSION['layout'] = '1';
}

Now at the minute when the user clicks the button to change the layout the div #fluidWrap fades out, the ajax request has 1 second to change the session data and add it to the database, and the page reloads. All works well.

I was wondering how I can improve on this to maybe make a transition effect where the page slides out and slides back in again, how would I go about doing this?

I can’t add an effect with jquery for the div #fluidWrap to fade in, as on every load of the page it will of course fade in. How can I tell jquery to only fade in the body if the button was clicked after a page load?

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/getting-a-nice-transition-effect-with-jquery-php-sessions-and-a-page-refresh/feed/ 0
Dynamically creating table using jQuery. Table is not getting displayed https://jqueryplugins.info/2011/10/dynamically-creating-table-using-jquery-table-is-not-getting-displayed/ https://jqueryplugins.info/2011/10/dynamically-creating-table-using-jquery-table-is-not-getting-displayed/#comments Tue, 04 Oct 2011 05:23:55 +0000 Admin https://jqueryplugins.info/2011/10/dynamically-creating-table-using-jquery-table-is-not-getting-displayed/ Post link: Dynamically creating table using jQuery. Table is not getting displayed

I am new to jQuery. I have to query 2 web services and based on an attribute value in first web service I have to query the next one and...

]]>
Post link: Dynamically creating table using jQuery. Table is not getting displayed

I am new to jQuery. I have to query 2 web services and based on an attribute value in first web service I have to query the next one and populate the result in a table using data from both web services.

Please have a look at the code at http://jsfiddle.net/ykPXZ/2/ . I am trying to append the table data to a div having id=”tableData”. I am getting the data from the web service and I have checked the console logs to see whether the data is getting appended to the variable tableDataA and it is getting appended but I am not to display the data on the web page. Somehow it is getting rewritten or deleted.

Please tell me if this is the best approach for solving this problem. Please suggest a better approach to it.

Thanks.

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/dynamically-creating-table-using-jquery-table-is-not-getting-displayed/feed/ 0
jQuery – Getting form values for ajax POST https://jqueryplugins.info/2011/09/jquery-getting-form-values-for-ajax-post/ https://jqueryplugins.info/2011/09/jquery-getting-form-values-for-ajax-post/#comments Thu, 15 Sep 2011 05:13:57 +0000 Admin https://jqueryplugins.info/2011/09/jquery-getting-form-values-for-ajax-post/ Post link: jQuery – Getting form values for ajax POST

I am trying to post form values via AJAX to a php file. How do I collect my form values to send inside of the “data” parameter? $ .ajax({ type:...

]]>
Post link: jQuery – Getting form values for ajax POST

I am trying to post form values via AJAX to a php file. How do I collect my form values to send inside of the “data” parameter?

$  .ajax({
        type: "POST",
        data: "submit=1&username="+username+"&email="+email+"&password="+password+"&passconf="+passconf,
        url: "http://rt.ja.com/includes/register.php",
        success: function(data)
        {
            //alert(data);
            $  ('#userError').html(data);
            $  ("#userError").html(userChar);
            $  ("#userError").html(userTaken);

        }
    });

HTML:

<div id="border">
            <form  action="/" id="registerSubmit">
            <div id="userError"></div>
            Username: <input type="text" name="username" id="username" size="10"/><br>
            <div id="emailError" ></div>
            Email: <input type="text" name="email" size="10" id="email"/><br>
            <div id="passError" ></div>
            Password: <input type="password" name="password" size="10" id="password"/><br>
            <div id="passConfError" ></div>
            Confirm Password: <input type="password" name="passconf" size="10" id="passconf"/><br>
                    <input type="submit" name="submit" value="Register" />

            </form>
        </div>

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/09/jquery-getting-form-values-for-ajax-post/feed/ 0
default values in input fields getting past validation on submission https://jqueryplugins.info/2011/09/default-values-in-input-fields-getting-past-validation-on-submission/ https://jqueryplugins.info/2011/09/default-values-in-input-fields-getting-past-validation-on-submission/#comments Thu, 15 Sep 2011 01:20:44 +0000 Admin https://jqueryplugins.info/2011/09/default-values-in-input-fields-getting-past-validation-on-submission/ Post link: default values in input fields getting past validation on submission

I wrote a small validation script (partially as an exercise in learning) but I can’t figure out how to make it detect default values in the input fields. It seems...

]]>
Post link: default values in input fields getting past validation on submission

I wrote a small validation script (partially as an exercise in learning) but I can’t figure out how to make it detect default values in the input fields. It seems like I need to store the default value in a variable and then add another OR in there to check if the current value matches that default value but I can’t quite figure out how to do that. I can’t put the variable inside the function executed on the click because then it takes the value at that point and uses that. Any help would be appreciated. I thought about just using “placeholder” but I wanted to make it work in IE. thanks in advance.

$  ('.submit').click(function() {
var ret_val = true;
var emailaddressVal = $  ("#email").val();
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$  /;
$  ('.required').each(function(){
if($  (this).val().length === 0 || $  (this).find("option:selected").val() == "none")
{
    $  ('#errormessage').removeClass('requiredmessage');
    ret_val = false;
    $  (this).addClass('warning');
}
else if($  (this).val().length != 0)
{
    $  (this).removeClass('warning');
}
});
if(!emailReg.test(emailaddressVal))
{
    $  ('#emailerrormessage').removeClass('requiredmessage');
    $  ('#email').addClass('warning');
    ret_val = false;
}
else
{
    $  ('#emailerrormessage').addClass('requiredmessage');
}
return ret_val;
});

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/09/default-values-in-input-fields-getting-past-validation-on-submission/feed/ 0
jQuery – Getting total depending on which checkboxes are selected https://jqueryplugins.info/2011/09/jquery-getting-total-depending-on-which-checkboxes-are-selected/ https://jqueryplugins.info/2011/09/jquery-getting-total-depending-on-which-checkboxes-are-selected/#comments Mon, 12 Sep 2011 07:17:30 +0000 Admin https://jqueryplugins.info/2011/09/jquery-getting-total-depending-on-which-checkboxes-are-selected/ Post link: jQuery – Getting total depending on which checkboxes are selected

I have a series of checkboxes that represent various food items. I would like to create a subtotal depending on what the user selects. I have been looking through the...

]]>
Post link: jQuery – Getting total depending on which checkboxes are selected

I have a series of checkboxes that represent various food items. I would like to create a subtotal depending on what the user selects. I have been looking through the jQuery documentation and I see how to update the the value of a textbox however how does one do a new tally every time a new checkbox is “checked”. Also, what happens when a checkbox is “un-selected”. Is there a way to store the value of each item in the HTML code of the checkbox?

I have a jsFiddle example I have been fooling with here …

http://jsfiddle.net/fQTUp/2/

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/09/jquery-getting-total-depending-on-which-checkboxes-are-selected/feed/ 0
getting xml without server side script? https://jqueryplugins.info/2011/08/getting-xml-without-server-side-script/ https://jqueryplugins.info/2011/08/getting-xml-without-server-side-script/#comments Wed, 31 Aug 2011 01:47:51 +0000 Admin https://jqueryplugins.info/2011/08/getting-xml-without-server-side-script/ Post link: getting xml without server side script?

Question by Kazuma: getting xml without server side script? Is it possible to retrieve an xml file on a different server from with in the HTML using something like Javascript...

]]>
Post link: getting xml without server side script?

Question by Kazuma: getting xml without server side script?
Is it possible to retrieve an xml file on a different server from with in the HTML using something like Javascript or Ajax? I tried using jQuery after I figured out ajax wouldn’t let me retrieve data that didn’t have the same host name but I recieve the same result.

Need some way to load the XML into html… I was thinking XLST but I can’t use it because I’m not the one creating the website. I’m only providing the backend. This XML should be included just by a simple Javascript function which converts and prints the XML into the HTML.

Best answer:

Answer by Alarice Chan
I’m not quite sure what script you can use to get content if JavaScript doesn’t work but it could be your server’s fault or the other server’s that the script couldn’t access the XML. XML should be accessible to the browser as long as your server allows others to integrate it to other websites and the other server also permits foreign server content (could be a security feature to prevent content stealing or cross-server scripting vulnerability).

What do you think? Answer below!

]]>
https://jqueryplugins.info/2011/08/getting-xml-without-server-side-script/feed/ 0