westman Posted April 19, 2012 Share Posted April 19, 2012 hi all its me again i am macking a form to be sent to javascript and then the info from the form send to a divi have this so fare... <script src="../js/jquery-1.4.2.js" type="text/javascript"></script><script language="javascript" type="text/javascript"> function sendname ( ) { var name1 = $("#name1");outname1 = document.getElementById("first");if (name1.val() == "") { $("#results").html('<img src="../image/round_error.png" alt="Error" width="31" height="30" /> Please type a first name.').show().fadeOut(6000); }else{outname1.textContent = name1;} }</script> but the last part or my code is not working. if i use...outname1.textContent = name1; oroutname1.innerHTML = name1; my output div value is "[object Object]"how do i fix the end of my script? Link to comment Share on other sites More sharing options...
eTianbun Posted April 19, 2012 Share Posted April 19, 2012 (edited) I have not realy gone through jquery tutorial, but i think: $('#name1') , was ment to get an element with an id 'name1' right? It should be something like this: $('#name1').value; to get the value of the form, instead of the object (element) itself. Edited April 19, 2012 by eTianbun Link to comment Share on other sites More sharing options...
westman Posted April 19, 2012 Author Share Posted April 19, 2012 am still geting [object Object] in my div insted of the name i type Link to comment Share on other sites More sharing options...
eTianbun Posted April 19, 2012 Share Posted April 19, 2012 Why not use js instead? Dont realy know why you are geting that: name1=document.getElementById('name1').value;outname1=document.getElementById('first');if(name1==''){/*You can add jquery here*/}else{outname1.innerHTML=name1} Link to comment Share on other sites More sharing options...
Ingolme Posted April 19, 2012 Share Posted April 19, 2012 It's an object. I'm not sure what you want to show, but you should find the property or method of that object that gives the value you're looking for. It looks like the .val() method might be what you're looking for. Link to comment Share on other sites More sharing options...
westman Posted April 19, 2012 Author Share Posted April 19, 2012 got it working <script src="../js/jquery-1.4.2.js" type="text/javascript"></script><script language="javascript" type="text/javascript"> function sendname ( ) { var name1 = $("#name1");outname1 = document.getElementById("first");if (name1.val() == "") { $("#results").html('<img src="../image/round_error.png" alt="Error" width="31" height="30" /> Please type a first name.').show().fadeOut(6000); }else{outname1.innerHTML = name1.val();} }</script> all i did was add.val() at the end of my code thank you so mush with the .val() thing Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now