HighDots Forums  

Why this code don't work

jQuery jQuery is a fast, concise, JavaScript Library that simplifies how you traverse HTML documents, handle events, perform animations, and add Ajax interactions to your web pages. jQuery is designed to change the way that you write JavaScript.


Discuss Why this code don't work in the jQuery forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
ReynierPM
 
Posts: n/a

Default Re: [jQuery] Why this code don't work - 11-03-2009 , 10:39 PM






Dhruva Sagar wrote:
Quote:
A minor mistake in the previous mail, please take this into consideration
and neglect the previous mail :

html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
head
script src="http://code.jquery.com/jquery-latest.pack.js"
type="text/javascript" language="javascript" charset="utf-8"></script
script type="text/javascript"
//<![CDATA[
$().ready(function(){
$('#clicy').click(function(){
var id = "word" + $('input[type!=hidden]').length;
var hid = "hw" + $('input[type=hidden]').length;
$('input[type=submit]').before('<br/><input type="hidden" name="'+hid+'"
id="'+hid+'" value="&&"/><label for="'+id+'">&&</label><input type="text"
name="'+id + '" id="'+id + '" value="" size="30" /><br/>');
return false;
});
$('#clico').click(function(){
var id = "word" + $('input[type!=hidden]').length;
var hid = "hw" + $('input[type=hidden]').length;
$('input[type=submit]').before('<br/><input type="hidden" name="'+hid+'"
id="'+hid+'" value="||"/><label for="'+id+'">||</label><input type="text"
name="'+id + '" id="'+id + '" value="" size="30" /><br/>');
return false;
});
});
//]]
/script
/head
body
form action="search/DoSearch" method="post"
label for="word">Texto:</label
input type="text" name="word" id="word" value="" size="50" /
div><input type="submit" value="Buscar !!!" /></div
/form
a href="" id="clicy">Adicionar criterio de búsqueda (&&)</a> | <a href=""
id="clico">Adicionar criterio de búsqueda (||)</a
/body
/html


Thanks & Regards,
Dhruva Sagar.


Stephen Leacock<http://www.brainyquote.com/quotes/authors/s/stephen_leacock.html
- "I detest life-insurance agents: they always argue that I shall some
day
die, which is not so."

On Wed, Nov 4, 2009 at 8:46 AM, Dhruva Sagar <dhruva.sagar (AT) gmail (DOT) com> wrote:


Thanks a lot, I made some improvements to your code because I'm using a
table now but it works perfectly.

--
Saludos
ReynierPM

Reply With Quote
  #12  
Old   
Dhruva Sagar
 
Posts: n/a

Default Re: [jQuery] Why this code don't work - 11-03-2009 , 10:40 PM






Great

Thanks & Regards,
Dhruva Sagar.


Marie von Ebner-Eschenbach<http://www.brainyquote.com/quotes/authors/m/marie_von_ebnereschenbac.html>
- "Even a stopped clock is right twice a day."

On Wed, Nov 4, 2009 at 9:09 AM, ReynierPM <rperezm (AT) uci (DOT) cu> wrote:

Quote:
Dhruva Sagar wrote:

A minor mistake in the previous mail, please take this into consideration
and neglect the previous mail :

html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
head
script src="http://code.jquery.com/jquery-latest.pack.js"
type="text/javascript" language="javascript" charset="utf-8"></script
script type="text/javascript"
//<![CDATA[
$().ready(function(){
$('#clicy').click(function(){
var id = "word" + $('input[type!=hidden]').length;
var hid = "hw" + $('input[type=hidden]').length;
$('input[type=submit]').before('<br/><input type="hidden" name="'+hid+'"
id="'+hid+'" value="&&"/><label for="'+id+'">&&</label><input type="text"
name="'+id + '" id="'+id + '" value="" size="30" /><br/>');
return false;
});
$('#clico').click(function(){
var id = "word" + $('input[type!=hidden]').length;
var hid = "hw" + $('input[type=hidden]').length;
$('input[type=submit]').before('<br/><input type="hidden" name="'+hid+'"
id="'+hid+'" value="||"/><label for="'+id+'">||</label><input type="text"
name="'+id + '" id="'+id + '" value="" size="30" /><br/>');
return false;
});
});
//]]
/script
/head
body
form action="search/DoSearch" method="post"
label for="word">Texto:</label
input type="text" name="word" id="word" value="" size="50" /
div><input type="submit" value="Buscar !!!" /></div
/form
a href="" id="clicy">Adicionar criterio de búsqueda (&&)</a> | <a href=""
id="clico">Adicionar criterio de búsqueda (||)</a
/body
/html


Thanks & Regards,
Dhruva Sagar.


Stephen Leacock
http://www.brainyquote.com/quotes/authors/s/stephen_leacock.html

- "I detest life-insurance agents: they always argue that I shall some
day
die, which is not so."

On Wed, Nov 4, 2009 at 8:46 AM, Dhruva Sagar <dhruva.sagar (AT) gmail (DOT) com
wrote:



Thanks a lot, I made some improvements to your code because I'm using a
table now but it works perfectly.

--
Saludos
ReynierPM

Reply With Quote
  #13  
Old   
ReynierPM
 
Posts: n/a

Default Re: [jQuery] Why this code don't work - 11-04-2009 , 07:26 PM



Dhruva Sagar wrote:
Quote:
Great

Hi again Dhruva:
I have one more question regarding this topic. How I can delete all the
newest elements created using the previous jQuery functions? Exists one
method for all or I need to build a custom function and clic as many
times as new elements I added?
Cheers
--
Saludos
ReynierPM

Reply With Quote
  #14  
Old   
Dhruva Sagar
 
Posts: n/a

Default Re: [jQuery] Why this code don't work - 11-04-2009 , 07:32 PM



Well I would suggest that you keep adding the generated id's of the inputs &
hidden inputs in an array.
Write a reset function which then loops through the array and selects them
using $() and call remove() for them to remove them from the DOM.

Other than that I don't think there is any way specifically that could allow
you to identify the inputs created from jquery uniquely.

Thanks & Regards,
Dhruva Sagar.




On Thu, Nov 5, 2009 at 5:56 AM, ReynierPM <rperezm (AT) uci (DOT) cu> wrote:

Quote:
Dhruva Sagar wrote:

Great


Hi again Dhruva:
I have one more question regarding this topic. How I can delete all the
newest elements created using the previous jQuery functions? Exists one
method for all or I need to build a custom function and clic as many times
as new elements I added?
Cheers
--
Saludos
ReynierPM

Reply With Quote
  #15  
Old   
Dhruva Sagar
 
Posts: n/a

Default Re: [jQuery] Why this code don't work - 11-05-2009 , 12:15 AM



Actually to think of it now, I see there is of course a much simpler easier
way to reset / remove all the newly added elements .

In your javascript where you add the elements to the dom, you can assign
them a particular css class say 'newly_added' . Then in the reset function
you could simply select them and remove them in one single swift action .

function reset() {
$('.newly_added').remove();
}

Thanks & Regards,
Dhruva Sagar.




On Thu, Nov 5, 2009 at 5:56 AM, ReynierPM <rperezm (AT) uci (DOT) cu> wrote:

Quote:
Dhruva Sagar wrote:

Great


Hi again Dhruva:
I have one more question regarding this topic. How I can delete all the
newest elements created using the previous jQuery functions? Exists one
method for all or I need to build a custom function and clic as many times
as new elements I added?
Cheers
--
Saludos
ReynierPM

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.