•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 401,502 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,273 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 2529 | Replies: 7
![]() |
•
•
Join Date: Feb 2008
Posts: 135
Reputation:
Rep Power: 1
Solved Threads: 3
Is any way to fill an ASP variable at clientside with javascript.
I like to use that value to send as a string with a textlink like described below.
<SELECT ONCHANGE="location = this.options[this.selectedIndex].value;">
<option value="">Choose something</option>
<option value="0">------------------</option>
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="3">option 3</option>
<option value="4">option 4</option>
<option value="5">option 5</option>
<option value="6">option 6</option>
</SELECT>
Val = 'option value from the dropmenu'
a href = "testpage.asp?value=<%Response.Write(Val)%>"> Textlink </a>
I like to use that value to send as a string with a textlink like described below.
<SELECT ONCHANGE="location = this.options[this.selectedIndex].value;">
<option value="">Choose something</option>
<option value="0">------------------</option>
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="3">option 3</option>
<option value="4">option 4</option>
<option value="5">option 5</option>
<option value="6">option 6</option>
</SELECT>
Val = 'option value from the dropmenu'
a href = "testpage.asp?value=<%Response.Write(Val)%>"> Textlink </a>
Last edited by TobbeK : Feb 19th, 2008 at 6:34 am.
•
•
Join Date: Jan 2008
Location: Bangalore, India
Posts: 336
Reputation:
Rep Power: 0
Solved Threads: 32
hi
change last line of <a..... tag as follow
-put one id attribute there
then:
-using javascript's getElementById() function get that anchor element.
-change the attribute href using function:
element.setAttribute("href","link_str");
-link_str is the complete text link string.
using above method you can dynamically change href attribute of anchor tag
change last line of <a..... tag as follow
-put one id attribute there
then:
-using javascript's getElementById() function get that anchor element.
-change the attribute href using function:
element.setAttribute("href","link_str");
-link_str is the complete text link string.
using above method you can dynamically change href attribute of anchor tag
A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila.
~Mitch Ratcliffe
~Mitch Ratcliffe
•
•
Join Date: Feb 2008
Posts: 135
Reputation:
Rep Power: 1
Solved Threads: 3
Hi, thanks for the reply. I'm not a javascripter so I need some more examples where to place the items
<SELECT ONCHANGE="link_str = element.setAttribute("href","link_str");">
<option value="">Choose something</option>
<option value="0">------------------</option>
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="3">option 3</option>
<option value="4">option 4</option>
<option value="5">option 5</option>
<option value="6">option 6</option>
</SELECT>
<a href = "testpage.asp?value=link_str">Textlink</a>
<SELECT ONCHANGE="link_str = element.setAttribute("href","link_str");">
<option value="">Choose something</option>
<option value="0">------------------</option>
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="3">option 3</option>
<option value="4">option 4</option>
<option value="5">option 5</option>
<option value="6">option 6</option>
</SELECT>
<a href = "testpage.asp?value=link_str">Textlink</a>
•
•
Join Date: Jan 2008
Location: Bangalore, India
Posts: 336
Reputation:
Rep Power: 0
Solved Threads: 32
learn some javascript, at least basics;
and some dom, it will help you to understand what i have written.
and some dom, it will help you to understand what i have written.
A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila.
~Mitch Ratcliffe
~Mitch Ratcliffe
•
•
Join Date: Feb 2008
Posts: 135
Reputation:
Rep Power: 1
Solved Threads: 3
Nope, doesn't work
I use this one instead, it makes a page reload but I can live with that.
<form id=frm action=select_menu.asp method=post>
<select name=optval onchange=frm.submit()>")
<option value="">Choose something</option>
<option value="">------------------</option>
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="3">option 3</option>
<option value="4">option 4</option>
<option value="5">option 5</option>
<option value="6">option 6</option>
</select>
</form>
<a href="menu.asp?id=<%=request.form("optval")%>">Link</a>
I use this one instead, it makes a page reload but I can live with that.
<form id=frm action=select_menu.asp method=post>
<select name=optval onchange=frm.submit()>")
<option value="">Choose something</option>
<option value="">------------------</option>
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="3">option 3</option>
<option value="4">option 4</option>
<option value="5">option 5</option>
<option value="6">option 6</option>
</select>
</form>
<a href="menu.asp?id=<%=request.form("optval")%>">Link</a>
Last edited by TobbeK : Feb 19th, 2008 at 12:45 pm.
Hi There,
I have Seen your Code and found that you are using frm.submit() function, in this function "frm" is the name of the form which you want submit, but you haven't define any name in form tag,
This Code Will Work
and you can do same thing with only using javascript:
Example:
Hope this will help you,
Rahul Dev Katarey
I have Seen your Code and found that you are using frm.submit() function, in this function "frm" is the name of the form which you want submit, but you haven't define any name in form tag,
This Code Will Work
<form name="frm" action="test.asp" method="post">
<select name="optval" onchange="frm.submit()">
<option value="">Choose something</option>
<option value="">------------------</option>
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="3">option 3</option>
<option value="4">option 4</option>
<option value="5">option 5</option>
<option value="6">option 6</option>
</select>
</form>
<a href="menu.asp?id=<%=request.form("optval")%>">Link</a>and you can do same thing with only using javascript:
Example:
<script type="text/javascript">
<!--//
//<![CDATA[
function changeHref(){
var linkToChange = document.getElementById('linkToChange');
linkText = "menu.asp?id="+document.getElementById('optval').value;
linkToChange.href = linkText;
}
//]]>
//-->
</script>
<select name="optval" onchange="changeHref()" id="optval">
<option value="">Choose something</option>
<option value="">------------------</option>
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="3">option 3</option>
<option value="4">option 4</option>
<option value="5">option 5</option>
<option value="6">option 6</option>
</select>
<a href="" id="linkToChange">Link</a>Hope this will help you,
Rahul Dev Katarey
Freelance Web Designer & Developer
Http//www.Katarey.com
Http//www.Katarey.com
Thats OK, just put a default links src for a tag, function will work as is,
thanks
Rahul Dev Katarey
<a href="menu.asp" id="linkToChange">Link</a> or <a href="menu.asp?id=what ever you want" id="linkToChange">Link</a>
thanks
Rahul Dev Katarey
Freelance Web Designer & Developer
Http//www.Katarey.com
Http//www.Katarey.com
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Previous Thread: Background music start
- Next Thread: Add remove rows javascript problem....


Linear Mode