By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,483 Members | 1,727 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,483 IT Pros & Developers. It's quick & easy.

to remove + and & when value is passed----its urgent

P: n/a

hi
ihad made a form in which dynamic rows are added to a table.
now when i send there values to next page by GETmethod then in between
alphabets where space is given + is shown and where new line is there &
is shown.
can anyone tell me how to solve this or get data in a proper way.
thanks
*** Sent via Developersdex http://www.developersdex.com ***
Sep 28 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a


Well:

var ducks='A+STRING+HERE&SECOND+LINE';
newducks=ducks.replace('\+',' ').replace('&','\n');
alert(newducks); // just use replace() on the string with it to
strip them.

Danny
Sep 28 '05 #2

P: n/a
thanks
iwill just try it n let u know

*** Sent via Developersdex http://www.developersdex.com ***
Sep 28 '05 #3

P: n/a

hi
ihad tried that code but a little error is there
1.i had all that boxes value stored in a array by using loop and its
also alternate arrays that have strings in it.
like array[1],array[3] etc.i.e.all odd ones have these values in it.so
how can i do replacing.

2.when i print in textarea like a d (in anew line)f
then output is ad%0D%0Af.
how the %0D%oA be removed

its really very urgent and imp
try to help me soon
thanks

DNT WORRY FROM PROBLEMS

*** Sent via Developersdex http://www.developersdex.com ***
Sep 28 '05 #4

P: n/a
garima puri wrote:
hi
ihad tried that code but a little error is there
1.i had all that boxes value stored in a array by using loop and its
also alternate arrays that have strings in it.
like array[1],array[3] etc.i.e.all odd ones have these values in it.so
how can i do replacing.
You can loop through the odd elements of the array and replace bits of
just what you want. To do an 'odd-element' loop:

for (var i=1, j=anArray.length; i<j; i+=2){
// do stuff
}

2.when i print in textarea like a d (in anew line)f
then output is ad%0D%0Af.
how the %0D%oA be removed


You need to unencode the values (the following just uses the submitted
URL to carry the form content to the next page):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>URI play</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<style type="text/css"></style>
<script type="text/javascript">

function updateTA()
{
var ta = document.forms['formA'].elements['tA'];
var u = location.href;
u = decodeURI( u.substring(((u.indexOf('=')+1) || u.length)));
u = u.replace(/\+/g,' ');

ta.value = u;
}

</script>
</head>
<body onload="updateTA();">
<p>Enter something into the text area, including returns, then press
submit. The text is returned in the URL, so it is captured, unencoded
and restored to the field.</p>
<form name="formA" action="">
<div>
<textarea name="tA" cols="50" rows="10"></textarea><br>
<input type="submit">
<input type="reset">
<input type="button" value="Odd count" onclick="
for (var i=1, j=10; i<j; i+=2){
alert(i);
}
">
</div>
</form>
</body></html>

If you want to support older browsers that don't support unencodeURI,
feature test and offer unescape too (it's depreciated but still widely
supported).

[...]

--
Rob
Sep 28 '05 #5

P: n/a
thanks
it all is useful
uwrote the coding of 1 textarea whereas i got the textarea generated
dynamically
its coding is:
function addRowToTable(val)
{
var tbl = document.getElementById(TABLE_NAME);
var nextRow = tbl.rows.length;
var iteration = nextRow - parseInt(headerRows) + parseInt(1);

// add the row
var row = tbl.insertRow(nextRow);

// CONFIG: This whole section can be configured

// cell 0 - text
var cell0 = row.insertCell(0);
var textNode = document.createTextNode(iteration);
//cell0.appendChild(textNode);

// cell 1 - input text
var cell1 = row.insertCell(1);
var txtInp = document.createElement('input');
txtInp.setAttribute('type', 'text');
txtInp.setAttribute('name', INPUT_NAME_PREFIX + iteration);
txtInp.setAttribute('size', '6');
txtInp.setAttribute('value', ''); // iteration included for debug
purposes
cell1.appendChild(txtInp);

// cell 2 - textarea
var cell2 = row.insertCell(2);
var txtAr = document.createElement('textarea')
txtAr.setAttribute('rows','4');
txtAr.setAttribute('cols','50');
txtAr.setAttribute('name',INPUT_NAME_PREFIX2 + iteration);
txtAr.setAttribute('id','newid');
//txtAr.setAttribute('value','Objectives:');

cell2.appendChild(txtAr);

//cell 3 - input button
var cell3 = row.insertCell(3);
var btnE1 = document.createElement('input');
btnE1.setAttribute('type','button');
btnE1.setAttribute('value','Delete Objective');
btnE1.onclick = function () {deleteCurrentRow(this) };
cell3.appendChild(btnE1);

//cell 4- input insert button
var cell4 = row.insertCell(4);
var btnE2 = document.createElement('input');
btnE2.setAttribute('type','button');
btnE2.setAttribute('value','Insert');
btnE2.onclick = function () {insertRow('tblSample',
'txtInsertIndex','errorMessage') };
cell4.appendChild(btnE2);
// Pass in the elements you want to reference later
// Store the myRow object in each row
row.myRow = new myRowObject(txtInp, txtAr);
}

now these values ican get

DNT WORRY FROM PROBLEMS

*** Sent via Developersdex http://www.developersdex.com ***
Sep 28 '05 #6

P: n/a
thanks
it all is useful
uwrote the coding of 1 textarea whereas i got the textarea generated
dynamically
its coding is:
function addRowToTable(val)
{
var tbl = document.getElementById(TABLE_NAME);
var nextRow = tbl.rows.length;
var iteration = nextRow - parseInt(headerRows) + parseInt(1);

// add the row
var row = tbl.insertRow(nextRow);

// CONFIG: This whole section can be configured

// cell 0 - text
var cell0 = row.insertCell(0);
var textNode = document.createTextNode(iteration);
//cell0.appendChild(textNode);

// cell 1 - input text
var cell1 = row.insertCell(1);
var txtInp = document.createElement('input');
txtInp.setAttribute('type', 'text');
txtInp.setAttribute('name', INPUT_NAME_PREFIX + iteration);
txtInp.setAttribute('size', '6');
txtInp.setAttribute('value', ''); // iteration included for debug
purposes
cell1.appendChild(txtInp);

// cell 2 - textarea
var cell2 = row.insertCell(2);
var txtAr = document.createElement('textarea')
txtAr.setAttribute('rows','4');
txtAr.setAttribute('cols','50');
txtAr.setAttribute('name',INPUT_NAME_PREFIX2 + iteration);
txtAr.setAttribute('id','newid');
//txtAr.setAttribute('value','Objectives:');

cell2.appendChild(txtAr);

//cell 3 - input button
var cell3 = row.insertCell(3);
var btnE1 = document.createElement('input');
btnE1.setAttribute('type','button');
btnE1.setAttribute('value','Delete Objective');
btnE1.onclick = function () {deleteCurrentRow(this) };
cell3.appendChild(btnE1);

//cell 4- input insert button
var cell4 = row.insertCell(4);
var btnE2 = document.createElement('input');
btnE2.setAttribute('type','button');
btnE2.setAttribute('value','Insert');
btnE2.onclick = function () {insertRow('tblSample',
'txtInsertIndex','errorMessage') };
cell4.appendChild(btnE2);
// Pass in the elements you want to reference later
// Store the myRow object in each row
row.myRow = new myRowObject(txtInp, txtAr);
}

now how these values ican get
iwant all that

DNT WORRY FROM PROBLEMS

*** Sent via Developersdex http://www.developersdex.com ***
Sep 28 '05 #7

P: n/a
garima puri wrote:
thanks
it all is useful
uwrote the coding of 1 textarea whereas i got the textarea generated
dynamically
its coding is:
Is there a question here?
function addRowToTable(val)
{
var tbl = document.getElementById(TABLE_NAME);
var nextRow = tbl.rows.length;
var iteration = nextRow - parseInt(headerRows) + parseInt(1);
If 'headerRows' is a string of digits, then the minus operator will
force it to be a number, so parseInt() is not required. There is never
any need to write parseInt(1).

var iteration = nextRow - headerRows + 1;

If you want belt 'n braces, use the unary operator '+' to force
headerRows to be a number:

var iteration = nextRow - +headerRows + 1;
If you insist on using parseInt (maybe to trim some trailing non-digit
characters), a radix parameter should be used:

var iteration = nextRow - parseInt(headerRows, 10) + 1;

// add the row
var row = tbl.insertRow(nextRow);

// CONFIG: This whole section can be configured

// cell 0 - text
var cell0 = row.insertCell(0);
var textNode = document.createTextNode(iteration);
//cell0.appendChild(textNode);

// cell 1 - input text
var cell1 = row.insertCell(1);
var txtInp = document.createElement('input');
txtInp.setAttribute('type', 'text');
[...]
now how these values ican get
iwant all that


Please use proper punctuation, this isn't e-mail.

I guess what you are asking is: if you submit the form to itself, how do
you parse the URL to get the names and values of all the form controls?

By getting the string after the first '?', split it on '&' to get the
name=value pairs, then loop through that array and split each one of
those to get the name and value.

So if you have your queryString:

var nameValues = queryString.split('&');
var i, j = nameValues.length;
var nameValue;
for (i=0; i<j; i++){
nameValue = nameValues[i].split('=');

// The control name is nameValue[0]
// The control value is nameValue[1]

nameValue[1] = deCode(nameValue[1]);

// Do something with the nameValue array
...
and deCode() goes something like:

function deCode( s )
{
s = s.replace(/\+/g,' ');
if (decodeURI) {
return decodeURI( s );
} else if (unencode) {
return unencode(s);
}
return s;
}

Untested but I'm sure you get the idea.

--
Rob
Sep 28 '05 #8

P: n/a
can u explain more

DNT WORRY FROM PROBLEMS

*** Sent via Developersdex http://www.developersdex.com ***
Sep 28 '05 #9

P: n/a
can u explain more
if i want these values to see on next page in a readonly way
how can i
explain pls
thanks

DNT WORRY FROM PROBLEMS

*** Sent via Developersdex http://www.developersdex.com ***
Sep 28 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.