Wednesday 15 January 2014

Removing multiple input names on output formdata strings/arrays with Javascript -


I understood it by using the global value / = on / g and it worked there ... thanks for the help ^ _ ^ Any other advice is appreciated! : D


I am currently having difficulty finding out that to remove formdata.Replace after the output all = on Tag with my form

I have several check boxes, which are presented to the next page and it displays all input data. However, it also keeps the = on tag from javascript and I can only understand how to remove one of them. I am assuming that I need to input any other loop elsewhere, but I am confused as to how to do this because there is an unknown checkbox number which they can choose at one time (this output Is being used on many pages, and there are different numbers per page).

This is the original script I found:

  & lt; Script type = "text / javascript" & gt; & Lt ;! - Hide from the built-in browser if (window! = Top) top.location.href = location.href document.write ("& lt; h1> your form has been submitted!  & lt ; H2 & gt; You entered the following data: & lt; / h2 & gt; "); Var formatta = location.search; FormData = formData.substring (1, formData.length); Whereas (formData.indexOf ("+")! = -1) {formData = formData.replace ("+", ""); } FormData = unescape (formData); Var Forere = form data. Split ("& amp;"); For (var i = 0; i  } // Hide from Blocker Browser - & gt; & Lt; / Script & gt;   

I added formData = formData.replace ("at", ""); While in the loop, which first removes one, but none other. I'm not sure where to place it, though.

You would like to be cautious of that code unless you expect user-generated input As you can end up taking some such space that you did not want to do, there are some JS libraries which will remove the submitted values ​​for you that you want to do research.

The problem you are facing is that it is only "at =" as often as "+" with "" If you add an additional time-loop, then you can change the "= on" until all of them are gone.

  while (formData.indexOf ("+")! = -1) {formData = formData.replace ("+", ""); } Whereas {formData.indexOf ("at =")! = -1) {formData = formData.replace ("=", "" ");}    

No comments:

Post a Comment