/    Sign up×
Community /Pin to ProfileBookmark

Help Create String Won’t work

I am using the script below in an html page. The resulting string is :
[url]http://www.375services.com/cgi-bin/MTV98.pl?DateRsvd=2008-12-01&DateRsvd=2008-12-12[/url]

My goal is
http://www.375services.com/cgi-bin/MTV98.pl?DateRsvd>2008-12-01&DateRsvd<2008-12-12

The script I am using is:
<script >
function CreateString() {
var startrange = document.getElementById(‘startrange’);
var endrange = document.getElementById(‘endrange’);
url url = “www.375services.com/cgi-bin/MTV98.pl?DateRsvd>’ + startrange.value + ‘&DateRsvd<‘ + endrange.value'”;

document.location.href = url;
}
</script>

As you can see , it supplies ‘equal sign” where I want Greater than and less than symbols.

Any ideas would be appreciated.

Tom Rector

to post a comment
JavaScript

9 Comments(s)

Copy linkTweet thisAlerts:
@FangDec 17.2008 — var url = <a href="https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference:Global_Functions:encodeURIComponent">encodeURIComponent</a>('www.375services.com/cgi-bin/MTV98.pl?DateRsvd&gt;' + startrange.value + '&amp;DateRsvd&lt;' + endrange.value);
Copy linkTweet thisAlerts:
@iamiauthorDec 18.2008 — Thanks for the response,


Changed the script to (below) still output 'equal' signs instead of 'greater than' and 'less than' signs.

<script >

function CreateString() {

var startrange = document.getElementById("startrange");

var endrange = document.getElementById("endrange");

var url = encodeURIComponent('www.375services.com/cgi-bin/MTV98.pl?DateRsvd>' + startrange.value + '&DateRsvd<' + endrange.value);

document.location.href = url;

}

</script>

What's wrong... output should be

http://www.375services.com/cgi-bin/MTV98.pl?DateRsvd>2008-12-01&DateRsvd<2008-12-12

instead of

http://www.375services.com/cgi-bin/MTV98.pl?DateRsvd=2008-12-01&DateRsvd=2008-12-12


Still respectfull of the 'experts'

Thanks again.

Tom
Copy linkTweet thisAlerts:
@FangDec 18.2008 — Outputs:

[I]www.375services.com&#37;2Fcgi-bin%2FMTV98.pl%3FDateRsvd>foo%26DateRsvd<bar[/I]

where [I]foo bar[/I] are the passed values

I would suspect the form action is being fired.

Add [I]return false[/I] to the function in the form.
Copy linkTweet thisAlerts:
@iamiauthorDec 19.2008 — Added return false; , Still not working symbols still output as 'equal' signs instead of 'greater than/less than'

signs.


Full form page w/script is located at http://www.375services.com/cgi-bin/MTV98.pl.

Please look, I really wanted to have this working Monday. I have spent many hours trying to make this one issue work.

Thanks again Tom Rector
Copy linkTweet thisAlerts:
@FangDec 19.2008 — And [I]onclick="[COLOR="Blue"]return[/COLOR] CreateString();"[/I]
Copy linkTweet thisAlerts:
@iamiauthorDec 20.2008 — Changed Submit to

<input type="submit" value="Load Range" onclick="return CreateString();">

No didn't change still gettinfg 'equal signs' in stead of greater than/less than signs.

Tom
Copy linkTweet thisAlerts:
@iamiauthorDec 21.2008 — Try a different approach

How can I make this string:

var url = (encodeURIComponent("/MTV98.pl'?DateRsvd>=' + startrange.value + '&DateRsvd<=' + endrange.value)");

Out put as :

/MTV98.pl?DateRsvd>=2008-12-01&DateRsvd<=2008-12-30

/// (2008-12-01=startrange.value and 2008-12-30= endrange.value)

output is a url, see full script above

The problen is, the ">=" and the "<=" signs, EncodeURIComponet does not pass < >

I don't have to do it tis way if someone has a better way.


Tom
Copy linkTweet thisAlerts:
@tivrfoaDec 21.2008 — wtf are you trying to do? ?

[code=html]<!-- create string -->
<script type='text/javascript'>
function createString() {
var startrange = document.getElementById('startrange');
var endrange = document.getElementById('endrange');
var url = 'http://www.375services.com/cgi-bin/MTV98.pl?DateRsvd>' +
startrange.value + '&DateRsvd<' + endrange.value;
document.location.href = url;
}
</script>
<body>
<input id='startrange' value='2008-12-01' />
<input id='endrange' value='2008-12-12' />
<input type='button' value='Create String' onclick='createString();' />
</body>[/code]


and what the **** the function name is "[B]c[/B]reateString" :eek:

function name "must" strat with lower case (just pattern)
Copy linkTweet thisAlerts:
@iamiauthorDec 21.2008 — Works ! Thanks !

The object was to create parameters for a perl script to check records in a flat file bewteen dates in the DateRsvd field.


Your fix works great, only one other nut to solve, I need the the "input" fields to be

between <form> tags, so I can use a script popup-calendar to input startrange and endrange. Appears this fix may have to work outside tags.

Thanks Again !, this has been a week long issue for me.
×

Success!

Help @iami spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...