Lonig Posted May 2, 2008 Share Posted May 2, 2008 Well, I have a very simple problem, just seems to be a problem in the syntax. I am very new to Javascript, so I'm sure its simple syntax or something. I've been searching for 30 minutes, and apparently I just dont know how to word my problem correctly. I'm sure its here, just cant find it.Here is the code in header: <script language="javascript" type="text/javascript"> function sendData(name) { window.open("http://www.blah.com?input=" + name,"Blah page","height=600,width=800"); }// End</script> Here is the body text <form><table border="0" cellpadding="2" cellspacing="0"> <tr> <td> <strong>Name: </strong> </td> <td> <input type="text" name="name" /> </td> </tr> <tr> <td colspan=2 align=center> <input type="button" value="Blah query" onclick="sendData(name)" /> </td> </tr></table></form> Purpose: I want to be able to type something in form, and have it be added to the end of the URL. Pretty much all I need.I apologize for such a simple post, but like I said, I've searched for 30 minutes on top of reading the code snippets and I just can't figure it out. I just hate to learn JavaScript when I never use it but once a few websites. Help me Guru's... help me. Link to comment Share on other sites More sharing options...
Ingolme Posted May 2, 2008 Share Posted May 2, 2008 The Javascript looks pretty correct to me, I don't see why it wouldn't work.You HTML could do with a bit of cleaning up, but that wouldn't affect this particular script.Can you link me to the page so I can check for errors myself? Link to comment Share on other sites More sharing options...
Lonig Posted May 2, 2008 Author Share Posted May 2, 2008 The Javascript looks pretty correct to me, I don't see why it wouldn't work.You HTML could do with a bit of cleaning up, but that wouldn't affect this particular script.Can you link me to the page so I can check for errors myself?They are internal pages on a ISP's LAN. Best I can offer is to tell you what happens when you click the button...It DOES open the window, but it looks like: http://www.blah.com?input=[object]Not sure if that helps? Link to comment Share on other sites More sharing options...
Ingolme Posted May 2, 2008 Share Posted May 2, 2008 Oh, I don't know how I didn't see it before.Change your form so that it's like this:<input type="text" id="name" /><input type="button" value="Blah query" onclick="sendData(document.getElementById('name').value)" /> Link to comment Share on other sites More sharing options...
Lonig Posted May 2, 2008 Author Share Posted May 2, 2008 Awesome, works great now. Thanks a bunch! Link to comment Share on other sites More sharing options...
Lonig Posted May 2, 2008 Author Share Posted May 2, 2008 EDIT: Nevermind, found my answer. I guess I might start learning Javascript after all, lots of neat features. Link to comment Share on other sites More sharing options...
Ingolme Posted May 2, 2008 Share Posted May 2, 2008 That's a little more complicated.You'd have to do something like this:<input type="radio" name="name" value="name1" /><input type="radio" name="name" value="name2" /><input type="button" value="Click me" onclick="radioButton('name')" />And then use the following Javascript function: function radioButton(N) { _radios = new Array(); for(var i=0;i<document.getElementsByTagName("input");i++) { if(document.getElementsByTagName("input")[i].type == "radio" && document.getElementsByTagName("input")[i].name == N) { _radios.push(document.getElementsByTagName("input")[i]); } } for(var n=0;n<_radios.length;n++) { if(_radios[n].checked) { window.open("http://www.blah.com?input=" + _radios[n].value,"Blah page","height=600,width=800"); } }} This is a long code and I haven't tested it myself, so it may not work. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.