Link to home
Start Free TrialLog in
Avatar of FairyBusiness
FairyBusinessFlag for United States of America

asked on

What is jquery's equivelant to echo in php??

Hi, I grabbed  a value from a form and put it into a var:

$('#submit').click(function() {
      var name = new String($('form: #name').val());
});

I want to display this value in a div on my page. . . but I cannot figure how to do that.  I tried document.write a few times, but either that does not work with jquery or I am doing it wrong.  Anyone know how to display variables in jquery??
Avatar of cmalakar
cmalakar
Flag of India image

$("#divId").html(varname);
Avatar of leakim971
This is append :

you div like this :

<div id="your_div_id"></div>

So :


$('#submit').click(function() {
      var name = $('#name').val();
      //$("#your_div_id").innerHTML(name);
      $("#your_div_id").append(name);
});

Open in new window

Avatar of FairyBusiness

ASKER

The only two that worked slighty were:

$('#submit').click(function() {
      var name = $('#name').val();
      $("#name1").html(name);
});

and

$('#submit').click(function() {
      var name = $('#name').val();
      $("#name1").append(name);
});

Ok, but its having a strange affect.  It shows on the page while its loading but then once its done loading or transmitting data its gone!  Its like it flashes on the page for 2 seconds, then nothing!!  ?????
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
what does the e mean?
and why do you comment out the .innerHTML???
Its not showing at all now:

http://auroriella.com/story.html

I am only testing the first value.  When you click Tell Story should show the name Tanya under hello
e for event (click) : http://api.jquery.com/event.preventDefault/

innerHTML replace
append add
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
and I can't locate the div with the div ID "your_div_id"
the lowercase 's' and append worked!!!  :)   Thanks
You're welcome! Thanks for the points!