Current location: Hot Scripts Forums » General Web Coding » JavaScript » remove element from html form when posting to http


remove element from html form when posting to http

Reply
  #1 (permalink)  
Old 10-10-09, 12:01 PM
RCGUA RCGUA is offline
New Member
 
Join Date: Oct 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
remove element from html form when posting to http

I have an html Form that I am posting to http. When I test the form and post it to http the element below shows up in the posted data. I only want the element to appear in the http output when the user selects something other than "once", if the user selects "once", then the element is not allow to be in the http output.

<select id = "Selection" name="shopping-cart.items.item-1.subscription.period">

The line below is the way it looks in the http result.

shopping-cart.items.item-1.subscription.period=ONCE

The javascript line below "disables" the element based on what the user selects in a drop down but does not remove the element from the http output.

DonateForm.elements["shopping-cart.items.item-1.quantity"].disabled=true;

The excellent script in the link below from job0107, does just what I need it to do, it removes elements from the Form, from what gets posted to http, I just can't figure out how to tweak it to make it work with my form.

http://www.hotscripts.com/forums/jav...tml#post124160
HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <script language="javascript" type="text/javascript">
function changeTagName()
{
var w = document.getElementById('Selection').value;
if(w == "ONCE")
{
DonateForm.elements["shopping-cart.items.item-1.subscription.period"].disabled=true;
}
else
{
alert("w DOES NOT equal once")
document.getElementById('MyTest').value="0.00";
}
}
    </script>
    <title></title>
  </head>
  <body>
<form method="post" action="https://sandbox.google.com/checkout/api/checkout/v2/checkoutForm/Merchant/777586971336777" accept-charset="utf-8">

      <select id = "Selection" name="shopping-cart.items.item-1.subscription.period">
        <option name="Option1" value="ONCE">
          ONCE
        </option>
        <option name="Option2" value="MONTHLY">
          MONTHLY
        </option>
        <option name="Option3" value="ANNUALLY">
          ANNUALLY
        </option>
      </select><br>
      <input id="MyTest" name="test" value="20" type="radio" checked> <b>$20</b> - Trains one teacher on how to provide safe drinking water at school<br>
      <input id="MyTest" name="test" value="50" type="radio"> <b>$50</b> - Provides educational materials for a class of 25 children<br>
      <input id="MyTest" name="test" value="100" type="radio"> <b>$100</b> - Provides educational materials for a class of 100 children<br> 

      <input type="submit" value="click to submit" onclick="changeTagName()">
    </form>
  </body>
</html>

Last edited by wirehopper; 10-10-09 at 12:57 PM. Reason: HTML tags
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 10-10-09, 12:58 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
Code:
DonateForm.elements["shopping-cart.items.item-1.quantity"].style.display='none';
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 10-10-09, 02:41 PM
RCGUA RCGUA is offline
New Member
 
Join Date: Oct 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for the help, I tested the code you posted and it still shows up in what gets posted to http. I think the code will make the element not appear in the html. Similarly, I think "remove.child" will make the element not show up in the browsers put the element remains in the code and shows up in what gets posted. The script from job0107 works, I just don't know how to alter it to work with my form.

http://www.hotscripts.com/forums/jav...tml#post124160
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 10-11-09, 06:06 PM
RCGUA RCGUA is offline
New Member
 
Join Date: Oct 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
This is solved. Form name was missing.

One little thing that was messing things up, I accidentally left the Form name off of the line of code I was using for posting http

<form method="post" action="https://sandbox.google.com/checkout/api/checkout/v2/check

<form ??Name of Form missing?? method="post"action="https://sandbox.google.com/checkout/a

it should be like below:

<form name="DonateForm" method="post" action=" . . . .
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 10-11-09, 09:10 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
You could try 'disabled="disabled"'.

You could also change the name to something meaningless, such as "_".

Might want to check at Google.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 10-12-09, 07:04 AM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
You might want to try accessing the input with document.getElementById('Selection'). I think that would work bettter.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks

Tags
elements, forms, html, javascript


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Space Above Form xavier039 CSS 1 07-13-09 11:52 PM
[SOLVED] CSS Error digioz CSS 12 07-06-09 04:09 PM
html form Gateux HTML/XHTML/XML 1 06-25-09 06:50 AM
Eliminating HTML element ben777 PHP 2 04-17-09 09:02 PM
[SOLVED] delay on html element properties? UnrealEd JavaScript 5 05-05-08 04:23 AM


All times are GMT -5. The time now is 10:27 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.