Nura111
asked on
how to get the value of a specific field using .attr or other in jquery
HI Im trying to get the <input type name="flag" value using jquery
I thought of using .attr function on the form element but I cant figure out how to get that
(Im doing it becuase I need to check if the form is sumbitted )
I thought of using .attr function on the form element but I cant figure out how to get that
(Im doing it becuase I need to check if the form is sumbitted )
<form id = "popup_form_{$row['id']}" name= "nurit" action ="" method ="post" style="background-color:white; border:2px solid blue;padding:4px; width:250px; display :none; position:absolute" onsubmit = "return false;">
<input type="hidden" name="id" value ="{$row['id']}">
<input type="hidden" name ="email" value ="{$row['email_address']}">
<input type ="hidden" name ="flag" value = "test" >
<input type="submit" value="SpamIt" name="spamIt" style="margin-right:15px;">
<input type="button" value="Close" onclick="closePopup()"/>
</form>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
var something = 10;
$(":hidden[name='flag']"). val( something );
or
$(":hidden[name='flag']"). attr("valu e", something);
$(":hidden[name='flag']").
or
$(":hidden[name='flag']").
ASKER
Hi the problem again is that I need something more uniqueI have more than one popup_form_{$row['id']}"
in the page how can I conecct to the id number of the form..
in the page how can I conecct to the id number of the form..
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
no its not working isnt the comma is adding the elements so it will chose 2 Dom element in that case?
ASKER
sorry it is working my mistake but still isnt comma is adding the elements so it will chose 2 Dom element in that case?
$("one,two")
is not
$("one" , "two")
if you prefer use the following :
$("#"+popup_form_id).find( ":hidden[n ame='flag' ]").val( something );
is not
$("one" , "two")
if you prefer use the following :
$("#"+popup_form_id).find(
ASKER
Thank you leakim971: Can we go back to the issue form yesterday
I can post it here or there
https://www.experts-exchange.com/questions/27325129/how-to-use-jquery-or-ajax-to-sumbit-a-form-to-a-process-php-file-and-display-the-result-on-the-main-page.html
the function that was handeling the click and that sumbiiting the form
I attached the form as well
So my only problem is that I want to update the db without changing anything in the page I think I need to use ajax but I dont know hoe to do it without loading anything to the element
I can post it here or there
https://www.experts-exchange.com/questions/27325129/how-to-use-jquery-or-ajax-to-sumbit-a-form-to-a-process-php-file-and-display-the-result-on-the-main-page.html
the function that was handeling the click and that sumbiiting the form
function toggleLeadBody(id) {
var fieldName1 = "#spam_"+ id + "_body";
var fieldName2 = "#sr_" + id + "_body";
var popup_form_id = "popup_form_" + id;
var element = $(fieldName2);
element.toggle();
var fElement = $(fieldName1);
//checking to see if its not been marked as spam
if ($(":hidden[name='flag']","#"+popup_form_id).val() =="no"){
fElement.toggle();
}
//sumbitting the form
fElement.submit(function(e) {
alert("Hello world!");
//fElement.attr('flag','1');
e.preventDefault();
//"mark" the input name =flag as spam
$(":hidden[name='flag']","#"+popup_form_id).val("on");
fElement.toggle();
})
}
I attached the form as well
So my only problem is that I want to update the db without changing anything in the page I think I need to use ajax but I dont know hoe to do it without loading anything to the element
<form id = "popup_form_{$row['id']}" action ="" method ="post" style="background-color:white; border:2px solid blue;padding:4px; width:250px; display :none; position:absolute" onsubmit = "return false;">
<input type ="hidden" name="flag" value = "no" >
<input type="hidden" name="id" value ="{$row['id']}">
<input type="hidden" name ="email" value ="{$row['email_address']}">
<input type="submit" value="SpamIt" name="spamIt" style="margin-right:15px;">
<input type="button" value="Close" onclick="closePopup()"/>
</form>
if THIS question is answered you MUST close it.
you may request attention for your other thread : I'm not alone here and not the best.
you may request attention for your other thread : I'm not alone here and not the best.
ASKER
ok I just thought you might be intrested you spend quite a while there at that question and I think it will be hard to follow for somebody else
ASKER