Southperry.net
Refreshing a single tag (HTML/Javascript question) - Printable Version

+- Southperry.net (https://www.southperry.net)
+-- Forum: Maplers Helping Maplers (https://www.southperry.net/forumdisplay.php?fid=9)
+--- Forum: Technical Help (https://www.southperry.net/forumdisplay.php?fid=84)
+--- Thread: Refreshing a single tag (HTML/Javascript question) (/showthread.php?tid=11398)



Refreshing a single tag (HTML/Javascript question) - butterfλi - 2009-05-17

So I've been searching the internets all day and haven't found anything on this so I'm wondering if it's possible. I should probably ask this on a HTML forum but then I'll forget my pw.

Anyway, the javascript function "window.location.reload()" will reload a whole page when its executed. However, I'm trying to modify it so that I can reload one tag instead of a whole page.

I was doing something along the lines of

Code:
<script language="JavaScript">
function loadThis() {
var loadThis = document.getElementById('lol');
loadThis.reload(); //I've also tried using "loadThis.location.reload()" but that didn't work either
}
</script>

<form action="#">
<select name=lol id=lol size=5>
<option value="1">a
<option value="2">b
<option value="3">c
</select>

<br>
<INPUT TYPE="button" value="Reload" onClick="javascript:loadThis()">
But that didn't go too well.


Refreshing a single tag (HTML/Javascript question) - Russt - 2009-05-17

Not really getting what you're trying to do here... refreshing the <select>? What for?

You can deselect all the options by getting each <option> and setting its selected attribute to false.


Refreshing a single tag (HTML/Javascript question) - butterfλi - 2009-05-17

Russt Wrote:Not really getting what you're trying to do here... refreshing the <select>?

Yeah, that's exactly what I'm trying to do. I actually have two functions working on the <select> tag. One is a .sort() function which sorts that given list by value. But once it's sorted, I can't "unsort" it so I'm trying to refresh it... a different method of "unsorting" it.


Refreshing a single tag (HTML/Javascript question) - Devil - 2009-05-17

I dont really get what you're trying but, did you ever try using <iframe> 's? :o

I dont think html / js can dynamically reload or update a page (or a form) without reloading it completly...


Refreshing a single tag (HTML/Javascript question) - butterfλi - 2009-05-17

No, not iframes.

A few shoutboxes for forums I've seen has refresh buttons. People can just refresh the shoutbox and the shoutbox would reload without having to reload the entire page.

If I came across a shoutbox like that again, I might have a better idea of what I'm doing lol (though I think shoutboxes are <div>'s? I'm not sure).


Refreshing a single tag (HTML/Javascript question) - Devil - 2009-05-17

butterfli Wrote:No, not iframes.

A few shoutboxes for forums I've seen has refresh buttons. People can just refresh the shoutbox and the shoutbox would reload without having to reload the entire page.

If I came across a shoutbox like that again, I might have a better idea of what I'm doing lol.
You could also make the shoutbox in flash, there should be a lot of tutorials for how to do it! Smile


Refreshing a single tag (HTML/Javascript question) - Russt - 2009-05-17

butterfli Wrote:Yeah, that's exactly what I'm trying to do. I actually have two functions working on the <select> tag. One is a .sort() function which sorts that given list by value. But once it's sorted, I can't "unsort" it so I'm trying to refresh it... a different method of "unsorting" it.
Ah. (I just lost the game.)

A... kind of iffy way of accomplishing that would be something like the following:

Code:
<script language="JavaScript">
function loadThis() {
var loadThis = document.getElementById('lol');
var inner = '<option value="1">a';
inner += '<option value="2">b';
inner += '<option value="3">c';
loadThis.innerHTML = inner;
}
</script>

...

<body onLoad = "loadThis()">

...

<form action="#">
<select name=lol id=lol size=5 onLoad = "javascript:loadThis()"></select>

<br>
<INPUT TYPE="button" value="Reload" onClick="javascript:loadThis()">

Basically just create the option tags in JavaScript, and do it again each time you hit the button.

I guess if you actually wanted to refresh it, you could do frames or something. Messy.

Devil Wrote:I dont think html / js can dynamically reload or update a page (or a form) without reloading it completly...
It can, and it's called AJAX. I don't think it's necessary for this, though.


Refreshing a single tag (HTML/Javascript question) - butterfλi - 2009-05-17

Russt Wrote:Basically just create the option tags in JavaScript, and do it again each time you hit the button.
Oh, nice. That works too. Thanks Poast+