Note that there are some explanatory texts on larger screens.

plurals
  1. POReplace "+" Character From URL Passed Variable in 2nd Page Form Field
    primarykey
    data
    text
    <p>I have a form on a home page and am trying to pass the input field value to another page with client-side only use. Issue is, I'd like to re-display the passed value back into another form field prior to running the function, but I cannot seem to be able to replace "+" character using REGEX (would also like to keep spacing). Any idea how I can accomplish this without much control?</p> <p><strong>1st Page Form:</strong></p> <pre><code> &lt;form id="dlrhpform" type="GET" action="/dealer-locator"&gt; &lt;div id="hp-form-input"&gt; &lt;div style="padding-left:20px;"&gt; &lt;p&gt;Enter address or zip code:&lt;/p&gt; &lt;input style="float:left;" type="text" id="hpaddress" name="hpaddress"/&gt; &lt;/div&gt; &lt;/div&gt; &lt;a href="javascript:;" onmouseover="MM_swapImage('hpsubmitbtn','','/btn_go_on.png',1)" onmouseout="MM_swapImgRestore()" /&gt; &lt;input onClick="_gaq.push(['_setAccount', 'UA-XXXXXXX-1'],['_trackEvent','Dealer Locator','Input Parameter', document.getElementById('hpaddress').value]);" style="position:relative; z-index:9999;" type="image" id="hpsubmitbtn" src="/btn_go.png" border="0" width="20" height="21" alt="hpsubmitbtn"/&gt; &lt;/form&gt; </code></pre> <p><strong>2nd Page Form:</strong></p> <pre><code> &lt;form name="user-location" id="user-location" method="post" action="#"&gt; &lt;div id="form-input" name="form-input"&gt; &lt;label for="address"&gt;Enter Address or Zip Code:&lt;/label&gt; &lt;input type="text" id="address" name="address" style="width:200px;"/&gt; &lt;/div&gt; &lt;div id="submit-btn"&gt;&lt;input name="fetch" type="image" src="/searchbutton.png" onclick="address.value=address.value.replace(/,/g,''); _gaq.push(['_setAccount', 'UA-XXXXXXX-1'],['_trackEvent','Dealer Locator','Input Parameter', document.getElementById('address').value]);"/&gt;&lt;/div&gt; &lt;/form&gt; </code></pre> <p><strong>2nd Page Script:</strong></p> <pre><code>//Return Home Page Address From URL var urladdress; if(document.URL.indexOf("hpaddress") &gt;= 0) { function getParams() { var idx = document.URL.indexOf('?'); parent.params = new Array(); if (idx != -1) { var pairs = document.URL.substring(idx+1, document.URL.length).split('&amp;'); for (var i=0; i&lt;pairs.length; i++) { nameVal = pairs[i].split('='); parent.params[nameVal[0]] = nameVal[1]; } } return params; } params = getParams(); urladdress = unescape(params["hpaddress"]); } window.onload = function() { if(typeof urladdress !== 'undefined') { document.getElementById("address").value = urladdress; } }; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload