/    Sign up×
Community /Pin to ProfileBookmark

Sending javascript value to page

Hi,

I haven’t got much javascript development experience but I think it’s probably the best solution to this: What I need to do is pass a variable to a page when clicking on a link. At least I think that’s what I want. One major facotr is I’m not allowed beyond 1.0 (unless there is no other solution). What I’ve got so far is this:

[CODE]<!–html form–><form name=”one” action=”myPage.asp” method=”post”><input name=”oneval” type=”hidden” value=”open” /></form>
<!–link with javascript–><a href=”javascript:document.one.submit”>link text</a>[/CODE]

That works spectacularly fine. The link sits in the page the form is invisible, click the link and it passes the hidden input’s value to the asp page. All lovely, but with two problems:

1) Everytime a user clicks the link they get the ‘Do you want to submit this form unencrypted across the internet” warning pop-up (unless they’ve disabled it). – which doesn’t exactly inspire confidence.
2) Not very elegant is it?

So, anyway to get the same result but bypass the form? Any help much appreciated.

cheers.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@GollumMay 20.2003 — Well, if there's only one thing to send to the server (or at least a small number) you could try encoding the value in the url...

<form name="one">

<input name="oneval" type="hidden" value="open">

</form>

<!--link with javascript-->

<a href="#" onclick="this.href = 'mywebsite.com?oneval=' + document.one.oneval.value;">link text</a>

what this does is as the user clicks on the link, you copy the value of the hidden into the into the url and set the href. Your ASP page can pick up the value using Request.QueryString("oneval")
Copy linkTweet thisAlerts:
@poabauthorMay 20.2003 — Aha! - thanks very much ?

I'm messing about with cookies at the moment but that solution looks to be the fastest for me at the moment

  • - thanks again.
  • ×

    Success!

    Help @poab 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 5.18,
    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: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

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

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...