473,394 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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


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
9 1933


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
thanks
iwill just try it n let u know

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

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
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
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
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
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
can u explain more

DNT WORRY FROM PROBLEMS

*** Sent via Developersdex http://www.developersdex.com ***
Sep 28 '05 #9
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ruel | last post by:
Is there an equivalent to the "Break When Value is True" Watch option in .NET. I have yet to discover it.
2
by: Ben Amada | last post by:
I'm a little confused about in what Event should I add dynamic controls and in what Event should I retrieve the value of a dynamic control on postback. I've found that adding dynamic controls in...
8
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);"...
5
by: omri | last post by:
Hi everyody, i have a complex problem (kind of urgent). i wrote a website in asp.net 2.0, one of the classes execute a java class (which is the steady part of the project ) by the way i'm doing...
32
by: Joe | last post by:
I am just starting to use Object Oriented PHP coding, and I am seeing quite often the following (this example taken from a wiki): $wakka =& new Wakka($wakkaConfig); What exactly is the =&, and...
1
by: vishwa Ram | last post by:
Hi ScriptFamily, I need to remove a duplicate value in array. Any specific method available in perl. pls suggest Regards Raam
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.