Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- jQuery Problem from JQuery beginner


snowweb - 1:13 pm on Mar 24, 2012 (gmt 0)


I've been thrown in the deep end, to fix something which is not really my responsibility but it's got to be fixed and no one else is going to do it, hence my lack of knowledge in this area. I've been trying to sort this now for the last 3 days solid and any assistance would be very much appreciated!

I have general knowledge of HTML, PHP and JavaScript, but no experience with jQuery.

First some HTML
<div id="popCustomer">
<table>
<tr>
<td>
<input name="cust_comp_name" type="text" maxlength="60" />
</td>
</tr>
<tr>
<td width="60%">
<input type="button" name="button" value="Save" onclick="addpop('popCustomer');" />
</td>
</tr>
</table>
</div>


The is the simplified code of a div layer which pops up above the page in response to a user generated event. It contains a table with an input box and a button.

When the button is pressed the "addpop" function should identify the input fields on the form (this one has only one, but others might have more) and add the contents to the database.

It's actually finished and is working perfectly in Firefox, but I need to get it to work in Chrome (Webkit). The problem is that the existing code uses navigation of the DOM to locate the input fields and the structure of the DOM is different in Chrome, so it fails.

I've heard that by using jQuery, it will work with both browsers, but I've never used it before and am finding it impossible to get started despite having spend all day reading jQuery introductions and examples.

What I'm thinking to do is to use jQuery to select and put in an array, all the form input fields including text, textarea and select types which are descendants (possibly distant) of the div with id="popCustomer". The array was also the result of the previous code, so it should work as a "drop-in" replacement.

As I mentioned I'm having major trouble getting my head around the syntax, even enough just to write the first line(!) after spending 12 hours, so far today studying it. All the tutorials seem to labor on and be based around the document.ready thing, but I just need to understand how to write standard lines of code to use in my function.

Please, please give me some pointers here. Thanks.


Thread source:: http://www.webmasterworld.com/javascript/4432954.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com