View Full Version : javascript/ajax output format

03-09-2010, 09:20 PM
hi, I have output code:

function setOutput(){
if(httpObject.readyState == 4){
document.getElementById('outputText').value = httpObject.responseText;


And the output is shown in the input place:

<input type="text" name="outputText" id="outputText" />

How I can get my output just as a text in <div></div> ???

Thanks :)

03-10-2010, 04:56 AM
Similar to how you had it in your other recent post that I responded to:

document.getElementById("txtHint").innerHTML = httpObject.responseText;

<div id="txtHint"></div>

03-10-2010, 04:10 PM
thanks :)

03-10-2010, 06:14 PM
httpObject.open("GET", "../ajx_script/talpinimas.php?id=reklama&paveikslelis="
+document.getElementById('paveikslelis').value+"&nikas="+<?php echo $nick; ?>

This assumes you've already done:

$nick = $_SESSION['nikas'];

earlier in the code and that the page is being parsed as .php.

However, if all you need is the value of $_SESSION['nikas'] be available on talpinimas.php, you could do it instead by taking it directly from the session variable on that page.

03-10-2010, 06:26 PM
OK, thanks again :)

Other thing...

I have youtube link like which user inserts into input, like:


And I need to get some part of this link as a variable which could add with <?php echo "$variable";?> in other place.

The part would be

03-10-2010, 07:36 PM
Not sure what you mean by "other place". You cannot get the value of v in:


into PHP without either:

Submitting it to a page via a form. Or

Doing something we've been discussing like an AJAX request to another PHP page.

But regardless of the method, it won't be available to PHP on the page you send it from, the PHP has already been parsed on that page. If you need it on that page, it could be gotten via javascript alone and then inserted via javascript alone wherever it's needed on that page. You could even do both, get and use it on the page with javascript, while also sending it to PHP via AJAX or a form submission for later use by PHP on other pages or even the next load of the current page.

Where's this "other place"?

03-10-2010, 08:13 PM
I will submit the data as I did before... line of operations looks like this:

inserting URL --> sending it to file.php --> read the part of URL and save it. That is all.

I am using Ajax just to send information, but everything works in other page: file.php (converting, ysql_real_escape_string, saving, etc...)

Do you need more specific info or a scipt part?