?
Solved

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

Posted on 2011-04-20
11
Medium Priority
?
235 Views
Last Modified: 2012-05-11
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??
0
Comment
Question by:FairyBusiness
  • 6
  • 4
11 Comments
 
LVL 23

Expert Comment

by:cmalakar
ID: 35438062
$("#divId").html(varname);
0
 
LVL 83

Expert Comment

by:leakim971
ID: 35438063
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

0
 

Author Comment

by:FairyBusiness
ID: 35438091
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!!  ?????
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 35438166
Use :
$('#Submit').click(function(e) {
      e.preventDefault();
      var name = $('#name').val();
      //$("#your_div_id").innerHTML(name);
      $("#your_div_id").append(name);
});

Open in new window

0
 

Author Comment

by:FairyBusiness
ID: 35438168
what does the e mean?
and why do you comment out the .innerHTML???
0
 

Author Comment

by:FairyBusiness
ID: 35438183
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
0
 
LVL 83

Expert Comment

by:leakim971
ID: 35438184
e for event (click) : http://api.jquery.com/event.preventDefault/

innerHTML replace
append add
0
 
LVL 83

Assisted Solution

by:leakim971
leakim971 earned 2000 total points
ID: 35438195
line 1 rename replace "S" by "s"

or rename your button "Submit" instead "submit"
0
 
LVL 83

Expert Comment

by:leakim971
ID: 35438198
and I can't locate the div with the div ID "your_div_id"
0
 

Author Closing Comment

by:FairyBusiness
ID: 35438201
the lowercase 's' and append worked!!!  :)   Thanks
0
 
LVL 83

Expert Comment

by:leakim971
ID: 35438211
You're welcome! Thanks for the points!
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question