If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > call function javascript from ASP, but with value to return

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-12-11, 12:03
jtorta jtorta is offline
Registered User
 
Join Date: Aug 2011
Posts: 2
call function javascript from ASP, but with value to return

Hello

I need someone to help me to be able to continue the development of a page in ASP code (not .NET)

I have a function in javascript (it's run fine), but I need call this function from ASP code by passing the value of a text variable retrieved from a database, for the function in javscript and manipulate the text and return this text with some change (CR replace with <br />, URL with anchor, ...)

I "only" need something like this (obviously does not work!)

<script>
function functionJS(value) {
//javascript code fot text manipulation
}
</script>
...
<body>
<% variable=functionJS(text); %>
<p><%= variable %></p>
</body>

If anyone can help me I would be grateful.

Thanks
Reply With Quote
  #2 (permalink)  
Old 08-13-11, 22:00
AnanthaP AnanthaP is offline
Registered User
 
Join Date: May 2009
Location: India
Posts: 62
I think what you need is:
(1) Change the javascript code to write the revised content to a hidden field on the form.
(2) Read the hidden field through the lhs=request("hidden_field")

OK
Reply With Quote
  #3 (permalink)  
Old 08-16-11, 13:00
jtorta jtorta is offline
Registered User
 
Join Date: Aug 2011
Posts: 2
Thank-you AnanthaP for help me.

It's not possible because I have a undefined number of contents recovered from data base, and I don't could generate a undefined number of hidden fields for make the conversion with javascript function.

Fortunately I found a function for implementing in ASP code for make the same function than in javavascript and I call this new function for convert the text fields recover from data base.

Thanks.
Reply With Quote
  #4 (permalink)  
Old 08-16-11, 20:43
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
can you give more details around what you are actually trying to achieve? This sounds like one of those problems where the solution is going to be quite different from the original approach taken.

What are you doing in your javascript function that can't be done in server side code?

If it has to be client side code then what does the output really look like?

One of your options might be to do something like....

Code:
<script>
function functionJS(value) {
    //javascript code fot text manipulation
    return "some changed text"
}

function reformat() {
    var contentDiv = document.getElementById("content");
    var hiddenValue= document.getElementById("serverText");
    contentDiv.innerText = reformat(hiddenValue.value);
}
</script>
...
<body onload="reformat();">
<input type="hidden" id="serverText" value="<%variable%>">
<% variable=functionJS(text); %>
<div id"content"></div>
</body>
Reply With Quote
Reply

Tags
asp, javascript

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On