User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 423,509 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 4,663 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 ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 894 | Replies: 4 | Solved
Reply
Join Date: Sep 2007
Posts: 81
Reputation: justapimp is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
justapimp justapimp is offline Offline
Junior Poster in Training

Help need help with javascript implementation

  #1  
Oct 1st, 2007
I have a device control panel that consist of a veiw and settings buttons. the buttons are binded to a dataset that populates the devicenumber and deviceUID
I have a javascrip function
function gotoGeo(username, name, duid)
{
	top.main.location.href="../TrackApp/main.aspx?selectedTab=" + selectedTab + "&deviceName=" + name + "&deviceUID=" + duid;
}
my buttons are programed to access this this function like this:
onclick='javascript:gotoGeo("<%# DataBinder.Eval(Container.DataItems "Name")%>", <%# DataBinder.Eval(Container.DataItems "UID")%>)'
because the device name can consist of blank spaces I surrounded that parameter between a double quotes.

On the code behind, I have another set of data that I am binding to. and that information cannot be binded to the button controls. So, I binded the data to an invisble textfield and Now i would like to use it as an input parameter to either the control or the javafunction

Can anyone help?

I try to use the method bellow but does not work.

I first create a variable name named
var name;

and assign the value of the textbox to the name variable
name = document.getElementById('txtUsername').value;

I then used that variable as the first parameter
in the onclick button behavior.
<input type="button" value="View" onclick='javascript:gotoGeo('name', "<%# DataBinder.Eval(Container.DataItems "Name")%>", <%# DataBinder.Eval(Container.DataItems "UID")%>);'>

since I am new to this web development and javascripting stuff, I don't know if the implementation is correct.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: need help with javascript implementation

  #2  
Oct 1st, 2007
Let me look into it, but I believe the var name is a reserved word, so you shouldn't use that. You're safest bet for that is to use txtName or just some letter before. The spaces shouldn't matter as much as it is just like a link. But, if it is possible, can't you bind your var name to a string and place it in programmatically? If you use vb, let the function deal with binding it. have the link lead to a function with your variables, and then pass the variables to your next function.

onclick='javascript:gotoGeo("<%# DataBinder.Eval(Container.DataItems "Name")%>", <%# DataBinder.Eval(Container.DataItems "UID")%>)'

(don't quote me on syntax.. )
Function gotoGeo(username, duid)
if (username == "" or duid == ""){
    Alert("Please fill in your required fields!");
} else {
    // pull the info from backend here and name it eName.
    var eName == "your pulled info"
    var selectedTab == "your pulled info"
    top.main.location.href="../TrackApp/main.aspx?selectedTab=" + selectedTab + "&deviceName=" + eName + "&deviceUID=" + duid;
}

This post would be better in the JSP or Javascript forum though, incase you wish to move or post a new one there.

Just throwin more insight
Reply With Quote  
Join Date: Sep 2007
Posts: 81
Reputation: justapimp is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
justapimp justapimp is offline Offline
Junior Poster in Training

Re: need help with javascript implementation

  #3  
Oct 1st, 2007
Here is the real question that I've been ponder over. Since the TextBox has been populated during the onload event shouln't it be possible to use the document.getElementById() method anywhere on the page? If so, How come the value is undefine?
Reply With Quote  
Join Date: Sep 2007
Posts: 81
Reputation: justapimp is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
justapimp justapimp is offline Offline
Junior Poster in Training

Re: need help with javascript implementation

  #4  
Oct 2nd, 2007
I solved the problem and think you for your suggestions. I couldn't have done without your input. What I did, was I allow the function to have two input parameters which will be supplied by the onclick event of the buttons.

I declared the variable username inside the gotoGeo method and I then call the document.getElementById() and assign it the txtUsername object (and it works).
Reply With Quote  
Join Date: Sep 2007
Posts: 1,057
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: need help with javascript implementation

  #5  
Oct 2nd, 2007
Glad to hear it! If there is no more, please click the Question Solved link at the bottom of the last post on the page. Hope all goes well!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 4:30 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC