Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

about submit and parameters

Status
Not open for further replies.

flac0

Programmer
Oct 31, 2001
22
UY
Hi!

I'm having problem with this situation: I have a page with somes checkbox and a button. When the user press the button
the page make a selfload and execute a java script serching for the elements of the page looking for those elements of type==checkbox (ask this for delete all selected items)... the java script it´s easy but have a problem... the problem is that the form haven´t the elements because (i guess) the script are executed before the elements appear again in the form... I think that the answer to this problem is searching the elements of the form in the parameters recived when the page are loading self...
it´s is possible? how? how can i search for the variables passed at himself by parameters?

(sorry that i don´t publicate the complete source, that's because the page are developed in erlang server pages .esp and it´s a bit confuse if you don´t are familiar with this language...if you are intersting in .esp i can send you somes examples latter. ;)

Thanks for all...me, the flac0!

here is my script:

<script>
if(confirm(&quot;delete all selected items?&quot;)){
for (var i = 0; i<parent.document.elements.length); i++){
if (parent.document.elements.type == &quot;checkbox&quot;){
if (parent.document.elements.checked){
**function to delete record**
}
}
}
}
</script>
My Development keyboard are on-fire! ;)
 
try testing for existence of &quot;type&quot; too:


<script>
if(confirm(&quot;delete all selected items?&quot;)){
e = parent.document.elements;
for (var i = 0; i<e.length); i++){
if (e.type && e.type == &quot;checkbox&quot;){
if (e.checked){
**function to delete record**
}
}
}
}
</script>
=========================================================
if (!succeed) try();
-jeff
 
Thanks Jemminger, but it doesn´t work... the problem it´s that parent.document.elements it´s not a defined object...js doesn´t see the parent document...

Doesn´t exist a class or method that let see the parameters recived by post or get method?

thanks again...flac0! [afro] My keyboard are on-fire baby! ;)
 
client-side javascript can't read GET or POST parameters because they exist in the HTTP header, which no longer exists after the page loads.

are you saying that this script runs in a new window that you open, and you want to read the form in the opener window? &quot;parent&quot; refers to the top-level window object of the current window - &quot;opener&quot; refers to the window that opened the current window, if any.

here is how you would do that:
[tt]
<script>
if(confirm(&quot;delete all selected items?&quot;)){
e = parent.opener.document.elements;
for (var i = 0; i<e.length); i++){
if (e[i].type && e[i].type == &quot;checkbox&quot;){
if (e[i].checked){
**function to delete record**
}
}
}
}
</script>
[/tt] =========================================================
if (!succeed) try();
-jeff
 
you could parse out key/value pairs from an input type submit (using location.href or location.search)

<script>document.write(&quot;<form id=my_form action=&quot; + location.href + &quot;>&quot;)</script>
<p>Choose your pizza:</p>
<p>
<input type=&quot;checkbox&quot; name=&quot;val_1&quot; value=&quot;salami&quot;> xtra cheesy<br>
<input type=&quot;checkbox&quot; name=&quot;val_2&quot; value=&quot;no_onions&quot;> no onions<br>
<input type=submit style=&quot;width:100;&quot; name=delete value=all>
</p>
</form>

<script>
if(location.search){
document.write(&quot;<b>deleting...</b><br>&quot;)
document.write(location.search)

// stip the key/value pairs
// do something...
}
</script>

</body>
</html>

hope this helps...

M°<=

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top